فهرست منبع

civetweb.c: fix potential memory leak in set_ports_options

Free 'ptr' in case realloc was successful, but the next check fails.

Fix for clang scan-build report:

5886 if (!success) {

    35 Potential leak of memory pointed to by 'ptr'

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf 11 سال پیش
والد
کامیت
bedc028f38
1فایلهای تغییر یافته به همراه1 افزوده شده و 0 حذف شده
  1. 1 0
      src/civetweb.c

+ 1 - 0
src/civetweb.c

@@ -5871,6 +5871,7 @@ static int set_ports_option(struct mg_context *ctx)
                           sizeof(ctx->listening_ports[0]))) == NULL) {
             closesocket(so.sock);
             so.sock = INVALID_SOCKET;
+            mg_free(ptr);
             success = 0;
         }
         else {