From ab162208617cbc69a7a7fe13a9e3e5349807f80b Mon Sep 17 00:00:00 2001
From: Sergey Lyubka <valenok@gmail.com>
Date: Fri, 10 May 2013 15:40:19 +0100
Subject: [PATCH] Not leaking socket in set ports option

---
 mongoose.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mongoose.c b/mongoose.c
index 94f1e50ec..a3b13dba0 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -4576,6 +4576,7 @@ static int set_ports_option(struct mg_context *ctx) {
     } else if ((ptr = realloc(ctx->listening_sockets,
                               (ctx->num_listening_sockets + 1) *
                               sizeof(ctx->listening_sockets[0]))) == NULL) {
+      closesocket(so.sock);
       success = 0;
     } else {
       set_close_on_exec(so.sock);
-- 
GitLab