lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [PATCH] httpd_raw: fix possible NULL pointer dereference


From: Michael Heimpold
Subject: [lwip-devel] [PATCH] httpd_raw: fix possible NULL pointer dereference
Date: Thu, 29 Oct 2015 20:28:35 +0100

This was found by a run of cppcheck. To fix this, simply
change the order of both checks.

Reported-by: Stefan Wahren <address@hidden>
Signed-off-by: Michael Heimpold <address@hidden>
---
 apps/httpserver_raw/httpd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/apps/httpserver_raw/httpd.c b/apps/httpserver_raw/httpd.c
index d0c3420..f2ced72 100644
--- a/apps/httpserver_raw/httpd.c
+++ b/apps/httpserver_raw/httpd.c
@@ -1535,16 +1535,16 @@ http_send(struct tcp_pcb *pcb, struct http_state *hs)
   LWIP_DEBUGF(HTTPD_DEBUG | LWIP_DBG_TRACE, ("http_send: pcb=%p hs=%p 
left=%d\n", (void*)pcb,
     (void*)hs, hs != NULL ? (int)hs->left : 0));
 
-#if LWIP_HTTPD_SUPPORT_POST && LWIP_HTTPD_POST_MANUAL_WND
-  if (hs->unrecved_bytes != 0) {
+  /* If we were passed a NULL state structure pointer, ignore the call. */
+  if (hs == NULL) {
     return 0;
   }
-#endif /* LWIP_HTTPD_SUPPORT_POST && LWIP_HTTPD_POST_MANUAL_WND */
 
-  /* If we were passed a NULL state structure pointer, ignore the call. */
-  if (hs == NULL) {
+#if LWIP_HTTPD_SUPPORT_POST && LWIP_HTTPD_POST_MANUAL_WND
+  if (hs->unrecved_bytes != 0) {
     return 0;
   }
+#endif /* LWIP_HTTPD_SUPPORT_POST && LWIP_HTTPD_POST_MANUAL_WND */
 
 #if LWIP_HTTPD_FS_ASYNC_READ
   /* Check if we are allowed to read from this file.
-- 
2.5.0




reply via email to

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