@cryptotaxi247 / netdata-1 / commits / 21e39a4ed

fix memory leak when using libcurl (#18947)

Costa Tsaousis committed Nov 6, 2024 at 08:40 UTC 21e39a4ed3f93d42c552a59d23e8e0f0ebd0ea11
1 file changed +3 -1
src/claim/claim-with-api.c
+3 -1
@@ -152,7 +152,7 @@ static bool send_curl_request(const char *machine_guid, const char *hostname, co
152 CURL *curl;
153 CURLcode res;
154 char target_url[2048];
155 - char public_key[2048] = ""; // Adjust size as needed
155 + char public_key[2048] = "";
156 FILE *fp;
157 struct curl_slist *headers = NULL;
158
@@ -266,6 +266,7 @@ static bool send_curl_request(const char *machine_guid, const char *hostname, co
266 if (res != CURLE_OK) {
267 claim_agent_failure_reason_set("Request failed with error: %s", curl_easy_strerror(res));
268 curl_easy_cleanup(curl);
269 + curl_slist_free_all(headers);
270 *can_retry = true;
271 return false;
272 }
@@ -348,6 +349,7 @@ static bool send_curl_request(const char *machine_guid, const char *hostname, co
349 }
350
351 curl_easy_cleanup(curl);
352 + curl_slist_free_all(headers);
353 return ret;
354 }
355