lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [patch #9525] httpd: add Websocket support


From: Jonathan D
Subject: [lwip-devel] [patch #9525] httpd: add Websocket support
Date: Wed, 9 Mar 2022 05:16:28 -0500 (EST)

Follow-up Comment #16, patch #9525 (project lwip):

I tested the patch and I found a memory leak. http_state_init(hs) can be
called with hs->ws_state pointing to an allocated struct and if hs is
resetted, this struct is never freed.

This patch can fix the leak :


Date:   Wed Mar 9 10:45:32 2022 +0100

    WebSocket : Fix a memory leak (httpd.c)

diff --git a/src/apps/httpd/httpd.c b/src/apps/httpd/httpd.c
index 96434a3d..0eef09ff 100644
--- a/src/apps/httpd/httpd.c
+++ b/src/apps/httpd/httpd.c
@@ -734,6 +734,9 @@ http_eof(struct altcp_pcb *pcb, struct http_state *hs)
 #if LWIP_HTTPD_SUPPORT_WEBSOCKET
   if (hs->is_websocket) {
     http_state_eof(hs);
+    if (NULL != hs->ws_state) {
+      HTTP_FREE_WEBSOCKET_STATE(hs->ws_state);
+    }
     http_state_init(hs);
     hs->is_websocket = 1;
   } else


    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?9525>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]