소스 검색

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 {