From 2b1c38995584f7c68a0123bd2eddb5eb9e161293 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 1 Mar 2010 18:43:37 +0000 Subject: [PATCH] Fixed accessing invalid memory when closing a listening pcb (introduced with tcp_shutdown) --- src/core/tcp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/tcp.c b/src/core/tcp.c index ca0dfaf4..c8ac2ad3 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -233,8 +233,10 @@ tcp_close(struct tcp_pcb *pcb) tcp_debug_print_state(pcb->state); #endif /* TCP_DEBUG */ - /* Set a flag not to receive any more data... */ - pcb->flags |= TF_RXCLOSED; + if (pcb->state != LISTEN) { + /* Set a flag not to receive any more data... */ + pcb->flags |= TF_RXCLOSED; + } /* ... and close */ return tcp_close_shutdown(pcb, 1); }