From 47ab4b0f988def2a8635f9bdea2886757830af26 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Wed, 20 Aug 2014 21:47:29 +0200 Subject: [PATCH] httpd: fix memory leak when LWIP_HTTPD_SUPPORT_REQUESTLIST==1 and connection is closed while trying to parse a request (should not happen on correct connections) --- apps/httpserver_raw/httpd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/httpserver_raw/httpd.c b/apps/httpserver_raw/httpd.c index e189268..f1b0da8 100644 --- a/apps/httpserver_raw/httpd.c +++ b/apps/httpserver_raw/httpd.c @@ -574,6 +574,12 @@ http_state_eof(struct http_state *hs) hs->ssi = NULL; } #endif /* LWIP_HTTPD_SSI */ +#if LWIP_HTTPD_SUPPORT_REQUESTLIST + if (hs->req) { + pbuf_free(hs->req); + hs->req = NULL; + } +#endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */ } /** Free a struct http_state. @@ -2342,6 +2348,8 @@ http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) || parsed == ERR_INPROGRESS ||parsed == ERR_ARG || parsed == ERR_USE); } else { LWIP_DEBUGF(HTTPD_DEBUG, ("http_recv: already sending data\n")); + /* already sending but still receiving data, we might want to RST here? */ + pbuf_free(p); } #if LWIP_HTTPD_SUPPORT_REQUESTLIST if (parsed != ERR_INPROGRESS) {