Correctly fix bug #49209: netconn_drain() fails to handle 'netconn_aborted' pointer

This commit is contained in:
goldsimon 2016-10-04 12:29:22 +02:00
parent d9c6badc55
commit cdc97d2779

View File

@ -781,16 +781,18 @@ netconn_drain(struct netconn *conn)
#if LWIP_TCP #if LWIP_TCP
if (sys_mbox_valid(&conn->acceptmbox)) { if (sys_mbox_valid(&conn->acceptmbox)) {
while (sys_mbox_tryfetch(&conn->acceptmbox, &mem) != SYS_MBOX_EMPTY) { while (sys_mbox_tryfetch(&conn->acceptmbox, &mem) != SYS_MBOX_EMPTY) {
struct netconn *newconn = (struct netconn *)mem; if (mem != &netconn_aborted) {
/* Only tcp pcbs have an acceptmbox, so no need to check conn->type */ struct netconn *newconn = (struct netconn *)mem;
/* pcb might be set to NULL already by err_tcp() */ /* Only tcp pcbs have an acceptmbox, so no need to check conn->type */
/* drain recvmbox */ /* pcb might be set to NULL already by err_tcp() */
netconn_drain(newconn); /* drain recvmbox */
if (newconn->pcb.tcp != NULL) { netconn_drain(newconn);
tcp_abort(newconn->pcb.tcp); if (newconn->pcb.tcp != NULL) {
newconn->pcb.tcp = NULL; tcp_abort(newconn->pcb.tcp);
newconn->pcb.tcp = NULL;
}
netconn_free(newconn);
} }
netconn_free(newconn);
} }
sys_mbox_free(&conn->acceptmbox); sys_mbox_free(&conn->acceptmbox);
sys_mbox_set_invalid(&conn->acceptmbox); sys_mbox_set_invalid(&conn->acceptmbox);