Reset the callbacks and arg (conn) to NULL in do_close_internal(), because

TCP callbacks in api_msg.c can under certain circumstances be called with an
invalid conn pointer after the connection has been closed (and conn has been
freed).
This commit is contained in:
marcbou 2007-08-26 23:58:33 +00:00
parent acbf25f2eb
commit 180e6d2c75

View File

@ -452,6 +452,12 @@ do_close_internal(struct netconn *conn)
if (err == ERR_OK) {
/* Closing succeeded */
conn->state = NETCONN_NONE;
/* Set back some callback pointers as conn is going away */
tcp_err(conn->pcb.tcp, NULL);
tcp_poll(conn->pcb.tcp, NULL, 4);
tcp_sent(conn->pcb.tcp, NULL);
tcp_recv(conn->pcb.tcp, NULL);
tcp_arg(conn->pcb.tcp, NULL);
conn->pcb.tcp = NULL;
conn->err = err;
/* Trigger select() in socket layer */