From 06c5c4d2a428b3320cb4eb335975a803c6b5f6d5 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov <rojer@cesanta.com> Date: Thu, 30 Mar 2017 16:19:02 +0100 Subject: [PATCH] Handle NULL tpcb in mg_lwip_tcp_write This can happen if the underlying LWIP TCP PCB has been destroyed (we got tcp_error_cb). PUBLISHED_FROM=7a060aa4ca2a0c5a818fe9bc6b08cd0733c0ef8f --- mongoose.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mongoose.c b/mongoose.c index 5697d5ed5..8bc2546ba 100644 --- a/mongoose.c +++ b/mongoose.c @@ -14313,6 +14313,7 @@ int mg_lwip_tcp_write(struct mg_connection *nc, const void *data, uint16_t len) { struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock; struct tcp_pcb *tpcb = cs->pcb.tcp; + if (tpcb == NULL) return -1; len = MIN(tpcb->mss, MIN(len, tpcb->snd_buf)); if (len == 0) { DBG(("%p no buf avail %u %u %u %p %p", tpcb, tpcb->acked, tpcb->snd_buf, -- GitLab