Fix bug #20315: possible memory leak problem if tcp_listen failed, because current code doesn't follow rawapi.txt documentation.

This commit is contained in:
fbernon 2007-07-13 13:59:11 +00:00
parent a2dffd430b
commit a891854ef5
2 changed files with 7 additions and 3 deletions

View File

@ -241,6 +241,10 @@ HISTORY
++ Bug fixes: ++ 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 2007-07-13 Kieran Mansley
* src/core/tcp_in.c Apply patch#5741 from Oleg Tyshev to fix bug in * src/core/tcp_in.c Apply patch#5741 from Oleg Tyshev to fix bug in
out of sequence processing of received packets out of sequence processing of received packets

View File

@ -513,7 +513,6 @@ do_delconn(struct api_msg_msg *msg)
/* conn->callback is called inside do_close_internal, before releasing /* conn->callback is called inside do_close_internal, before releasing
the application thread, so we can return at this point! */ the application thread, so we can return at this point! */
return; return;
break;
#endif /* LWIP_TCP */ #endif /* LWIP_TCP */
default: default:
break; break;
@ -675,8 +674,8 @@ do_listen(struct api_msg_msg *msg)
if (msg->conn->err == ERR_OK) { if (msg->conn->err == ERR_OK) {
if (msg->conn->pcb.tcp != NULL) { if (msg->conn->pcb.tcp != NULL) {
if (msg->conn->type == NETCONN_TCP) { if (msg->conn->type == NETCONN_TCP) {
msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp); struct tcp_pcb* lpcb = tcp_listen(msg->conn->pcb.tcp);
if (msg->conn->pcb.tcp == NULL) { if (lpcb == NULL) {
msg->conn->err = ERR_MEM; msg->conn->err = ERR_MEM;
} else { } else {
if (msg->conn->acceptmbox == SYS_MBOX_NULL) { if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
@ -685,6 +684,7 @@ do_listen(struct api_msg_msg *msg)
} }
} }
if (msg->conn->err == ERR_OK) { if (msg->conn->err == ERR_OK) {
msg->conn->pcb.tcp = lpcb;
tcp_arg(msg->conn->pcb.tcp, msg->conn); tcp_arg(msg->conn->pcb.tcp, msg->conn);
tcp_accept(msg->conn->pcb.tcp, accept_function); tcp_accept(msg->conn->pcb.tcp, accept_function);
} }