From 43a08bef142bdd4b60ce5bb43ea8bce51e86ba3b Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sat, 6 Mar 2010 12:06:27 +0000 Subject: [PATCH] tcp_accepted(): check pcb state to verify it isn't called on a connection-pcb --- src/include/lwip/tcp.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index 5fcc7a3f..f11b4cf3 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -328,9 +328,12 @@ void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err); #define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) #if TCP_LISTEN_BACKLOG -#define tcp_accepted(pcb) (((struct tcp_pcb_listen *)(pcb))->accepts_pending--) +#define tcp_accepted(pcb) do { \ + LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", pcb->state == LISTEN); \ + (((struct tcp_pcb_listen *)(pcb))->accepts_pending--); } while(0) #else /* TCP_LISTEN_BACKLOG */ -#define tcp_accepted(pcb) LWIP_UNUSED_ARG(pcb); +#define tcp_accepted(pcb) LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", \ + pcb->state == LISTEN) #endif /* TCP_LISTEN_BACKLOG */ void tcp_recved (struct tcp_pcb *pcb, u16_t len);