From a891854ef5f4901f36b2783dee404bd97b64ecfd Mon Sep 17 00:00:00 2001 From: fbernon Date: Fri, 13 Jul 2007 13:59:11 +0000 Subject: [PATCH] Fix bug #20315: possible memory leak problem if tcp_listen failed, because current code doesn't follow rawapi.txt documentation. --- CHANGELOG | 4 ++++ src/api/api_msg.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 301fc87a..cdb45642 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -241,6 +241,10 @@ HISTORY ++ Bug fixes: + 2007-07-13 Frédéric Bernon + * api_msg.c: Fix bug #20315: possible memory leak problem if tcp_listen failed, + because current code doesn't follow rawapi.txt documentation. + 2007-07-13 Kieran Mansley * src/core/tcp_in.c Apply patch#5741 from Oleg Tyshev to fix bug in out of sequence processing of received packets diff --git a/src/api/api_msg.c b/src/api/api_msg.c index 2f866448..0d7b31d6 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -513,7 +513,6 @@ do_delconn(struct api_msg_msg *msg) /* conn->callback is called inside do_close_internal, before releasing the application thread, so we can return at this point! */ return; - break; #endif /* LWIP_TCP */ default: break; @@ -675,8 +674,8 @@ do_listen(struct api_msg_msg *msg) if (msg->conn->err == ERR_OK) { if (msg->conn->pcb.tcp != NULL) { if (msg->conn->type == NETCONN_TCP) { - msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp); - if (msg->conn->pcb.tcp == NULL) { + struct tcp_pcb* lpcb = tcp_listen(msg->conn->pcb.tcp); + if (lpcb == NULL) { msg->conn->err = ERR_MEM; } else { if (msg->conn->acceptmbox == SYS_MBOX_NULL) { @@ -685,6 +684,7 @@ do_listen(struct api_msg_msg *msg) } } if (msg->conn->err == ERR_OK) { + msg->conn->pcb.tcp = lpcb; tcp_arg(msg->conn->pcb.tcp, msg->conn); tcp_accept(msg->conn->pcb.tcp, accept_function); }