From: Mateusz Moscicki Date: Tue, 15 Jun 2021 10:12:53 +0000 (+0200) Subject: Fix coverity issue - resource leak X-Git-Tag: submit/tizen/20210615.154137^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e0d7fb1b73e6fc9599e179bc79417904305b53f;p=platform%2Fcore%2Fsystem%2Fupdate-control.git Fix coverity issue - resource leak Change-Id: Icf860015ab0ae692a14ce2c46af67770f2b30a7c --- diff --git a/src/plugin/http_util.c b/src/plugin/http_util.c index 7b826dc..05b4b3f 100644 --- a/src/plugin/http_util.c +++ b/src/plugin/http_util.c @@ -255,7 +255,8 @@ int http_util_check_request_to_fota(const char *uid, retvm_if(!curl, -EIO, "Failed to init curl"); 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); + retvmf_if(CURLE_OK != curl_ret_code, -EIO, curl_easy_cleanup(curl), + "Failed to curl_easy_setopt with CURLOPT_HTTPGET : ret_code[%d]", curl_ret_code); tmp_header = g_strconcat("X-IOT-UID: ", uid, NULL); header = curl_slist_append(header, tmp_header); @@ -265,7 +266,8 @@ int http_util_check_request_to_fota(const char *uid, g_free(tmp_header); curl_ret_code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header); - retvm_if(CURLE_OK != curl_ret_code, -EIO, "Failed to curl_easy_setopt with CURLOPT_HTTPHEADER : ret_code[%d]", curl_ret_code); + retvmf_if(CURLE_OK != curl_ret_code, -EIO, curl_easy_cleanup(curl), + "Failed to curl_easy_setopt with CURLOPT_HTTPHEADER : ret_code[%d]", curl_ret_code); snprintf(query, sizeof(query), "?deviceType=%s¤tVersion=%s", device_type, current_version); req_url = g_strconcat(STDM_URL, query, NULL); diff --git a/src/plugin/plugin.h b/src/plugin/plugin.h index 48865b2..e09a833 100644 --- a/src/plugin/plugin.h +++ b/src/plugin/plugin.h @@ -42,6 +42,9 @@ extern "C" #define retvm_if(expr, val, fmt, arg...) \ do { if (expr) { _E(fmt, ##arg); return (val); } } while (0) +#define retvmf_if(expr, val, func, fmt, arg...) \ + do { if (expr) { _E(fmt, ##arg); func; return (val); } } while (0) + #ifdef __cplusplus } #endif