AmendHub

Download:

jcs

/

subtext

/

amendments

/

348

telnet: Handle malloc failure


jcs made amendment 348 about 1 year ago
--- telnet.c Sun Feb 5 11:13:11 2023 +++ telnet.c Wed Mar 1 16:38:44 2023 @@ -166,8 +166,9 @@ telnet_init(void) /* pre-allocate nodes */ for (n = 0; n < MAX_TELNET_NODES; n++) { - telnet_nodes[n] = xmalloczero(sizeof(struct telnet_node), - "telnet node"); + telnet_nodes[n] = xmalloczero(sizeof(struct telnet_node)); + if (telnet_nodes[n] == NULL) + panic("Failed allocating telnet node %d", n); telnet_nodes[n]->id = n; if (n == 0) @@ -176,7 +177,9 @@ telnet_init(void) if (db->config.trusted_proxy_ip != 0 && db->config.trusted_proxy_udp_port != 0) { - udp_ban_rcv_buf = xmalloc(UDP_BAN_RCV_BUF_SIZE, "udp_ban_rcv_buf"); + udp_ban_rcv_buf = xmalloc(UDP_BAN_RCV_BUF_SIZE); + if (udp_ban_rcv_buf == NULL) + panic("Failed allocating UDP ban buf"); error = _UDPCreate(&udp_ban_pb, &udp_ban_stream, (Ptr)udp_ban_rcv_buf, UDP_BAN_RCV_BUF_SIZE, NULL, NULL, NULL, false);