From d43beb750651f75f9dcb5f18123008ba9e93352f Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 12 Sep 2019 18:00:06 +0200 Subject: Fixed code flow with memory free --- common/http.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/http.c b/common/http.c index 0a87b6a..9ad091d 100644 --- a/common/http.c +++ b/common/http.c @@ -90,7 +90,6 @@ const char * http_perform(const char* path, const char* postfields) strcpy(url, weburl); strcpy(url + weburl_len, path); curl_easy_setopt(curl, CURLOPT_URL, url); - free(url); if (postfields != NULL) curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postfields); if (headers != NULL) @@ -98,8 +97,10 @@ const char * http_perform(const char* path, const char* postfields) CURLcode res = curl_easy_perform(curl); if(res != CURLE_OK) { fprintf(stderr, "HTTP get to %s failed: %s\n", url, curl_easy_strerror(res)); + free(url); return NULL; } + free(url); return buffer; } -- cgit v1.2.3