From 1f01634029214f7dfd24e2eca2d24521abb6d1f7 Mon Sep 17 00:00:00 2001 From: christiaans Date: Wed, 14 Jun 2006 08:02:35 +0000 Subject: [PATCH] Applied patch #5146 to handle allocation failures in accept() by Kevin Lawson. --- src/api/api_msg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/api_msg.c b/src/api/api_msg.c index 0cbe626f..25d34048 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -228,9 +228,6 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) if (newconn == NULL) { return ERR_MEM; } - newconn->type = NETCONN_TCP; - newconn->pcb.tcp = newpcb; - setup_tcp(newconn); newconn->recvmbox = sys_mbox_new(); if (newconn->recvmbox == SYS_MBOX_NULL) { memp_free(MEMP_NETCONN, newconn); @@ -249,6 +246,10 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) memp_free(MEMP_NETCONN, newconn); return ERR_MEM; } + /* Allocations were OK, setup the PCB etc */ + newconn->type = NETCONN_TCP; + newconn->pcb.tcp = newpcb; + setup_tcp(newconn); newconn->acceptmbox = SYS_MBOX_NULL; newconn->err = err; /* Register event with callback */