From 3cdec82e570b204e145d04512f0972bbebecc6ce Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 23 May 2018 10:39:39 +0200 Subject: [PATCH] Fixing memory leak when using req_setopt --- esp_request.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esp_request.c b/esp_request.c index cc7ec7d..d9a8ed0 100644 --- a/esp_request.c +++ b/esp_request.c @@ -348,9 +348,10 @@ void req_setopt(request_t *req, REQ_OPTS opt, void* data) int post_len; char len_str[10] = {0}; req_list_t *tmp; - char *host_w_port = malloc(1024); + char *host_w_port = NULL; if(!req || !data) return; + host_w_port = malloc(1024); switch(opt) { case REQ_SET_METHOD: req_list_set_key(req->opt, "method", data);