瀏覽代碼

Avoid memory leaks if duplicate options are passed.

nullable.type 12 年之前
父節點
當前提交
eb92b5f1b3
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      mongoose.c

+ 1 - 0
mongoose.c

@@ -4976,6 +4976,7 @@ struct mg_context *mg_start(mg_callback_t user_callback, void *user_data,
     }
     }
     if (ctx->config[i] != NULL) {
     if (ctx->config[i] != NULL) {
       cry(fc(ctx), "warning: %s: duplicate option", name);
       cry(fc(ctx), "warning: %s: duplicate option", name);
+      free(ctx->config[i]);
     }
     }
     ctx->config[i] = mg_strdup(value);
     ctx->config[i] = mg_strdup(value);
     DEBUG_TRACE(("[%s] -> [%s]", name, value));
     DEBUG_TRACE(("[%s] -> [%s]", name, value));