From e7c0619189e6a9df04f98b15e881655142fd67f3 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Tue, 12 Jun 2018 13:32:12 +0200 Subject: [PATCH] fix NULL checks (compiler error, tcp_rst allows pcb==NULL) --- src/core/tcp.c | 5 ++++- src/core/tcp_out.c | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/tcp.c b/src/core/tcp.c index b97fbf69..0362aab5 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -1534,10 +1534,13 @@ tcp_txnow(void) err_t tcp_process_refused_data(struct tcp_pcb *pcb) { +#if TCP_QUEUE_OOSEQ && LWIP_WND_SCALE + struct pbuf *rest; +#endif /* TCP_QUEUE_OOSEQ && LWIP_WND_SCALE */ + LWIP_ERROR("tcp_process_refused_data: invalid pcb", pcb != NULL, return ERR_ARG); #if TCP_QUEUE_OOSEQ && LWIP_WND_SCALE - struct pbuf *rest; while (pcb->refused_data != NULL) #endif /* TCP_QUEUE_OOSEQ && LWIP_WND_SCALE */ { diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index 2ad19b91..91f56aad 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -1886,7 +1886,7 @@ tcp_output_fill_options(const struct tcp_pcb *pcb, struct pbuf *p, u8_t optflags #endif #if LWIP_TCP_SACK_OUT - if (num_sacks > 0) { + if (pcb && (num_sacks > 0)) { tcp_build_sack_option(pcb, opts, num_sacks); /* 1 word for SACKs header (including 2xNOP), and 2 words for each SACK */ sacks_len = 1 + num_sacks * 2; @@ -1979,7 +1979,6 @@ tcp_rst(const struct tcp_pcb *pcb, u32_t seqno, u32_t ackno, u16_t wnd; u8_t optlen; - LWIP_ASSERT("tcp_rst: invalid pcb", pcb != NULL); LWIP_ASSERT("tcp_rst: invalid local_ip", local_ip != NULL); LWIP_ASSERT("tcp_rst: invalid remote_ip", remote_ip != NULL);