From: SangYoun Kwak Date: Mon, 19 Feb 2024 02:21:53 +0000 (+0900) Subject: plugin: Fix http_util_send_request to free resources X-Git-Tag: accepted/tizen/8.0/unified/20240312.060836~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd004838dbce6d1a784e58f1b176da0e1eb572b2;p=platform%2Fcore%2Fsystem%2Fupdate-control.git plugin: Fix http_util_send_request to free resources In the function http_util_send_request, it was not freeing resources which it allocated properly. To make it to free resources properly, return statements are fixed to 'goto END;' statement. Change-Id: Idd905ed10098a2403acf609d98c273b86ed72f4a Signed-off-by: SangYoun Kwak --- diff --git a/src/plugin/http_util.c b/src/plugin/http_util.c index 5bacc8a..11ba36b 100644 --- a/src/plugin/http_util.c +++ b/src/plugin/http_util.c @@ -403,19 +403,29 @@ int http_util_send_request(fmwup_http_e type, const char *req_url, char **res_he if (type == FMWUP_HTTP_GET) { curl_ret_code = curl_easy_setopt(curl, CURLOPT_HTTPGET, 1); - retvm_if(CURLE_OK != curl_ret_code, -EIO, "Failed to curl_easy_setopt with CURLOPT_HTTPGET : ret_code[%d]", curl_ret_code); + if (CURLE_OK != curl_ret_code) { + _E("Failed to curl_easy_setopt with CURLOPT_HTTPGET : ret_code[%d]", curl_ret_code); + ret = -EIO; + goto END; + } } else if (type == FMWUP_HTTP_POST) { mime = curl_mime_init(curl); - retvm_if(!mime, -EIO, "curl_mime_init: Failed to init mime"); + if (!mime) { + _E("curl_mime_init: Failed to init mime"); + ret = -EIO; + goto END; + } curl_ret_code = curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime); if (curl_ret_code != CURLE_OK) { - curl_mime_free(mime); _E("Failed to curl_easy_setopt with CURLOPT_MIMEPOST : ret_code[%d]", curl_ret_code); - return -EIO; + ret = -EIO; + goto END; } } else { - return -1; + _E("Invalid http type: %d", type); + ret = -1; + goto END; } __curl_set_common_option(curl, (const char *)req_url, &response_header, &response_body);