From: dyamy-lee Date: Tue, 4 Feb 2025 02:51:03 +0000 (+0900) Subject: Fix defects detected by coverity tool X-Git-Tag: accepted/tizen/unified/20250305.160207^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c587d91c4301303774e2377c8cf66a2667e5b338;p=platform%2Fcore%2Fuifw%2Fmulti-assistant.git Fix defects detected by coverity tool To prevent memory leak, checking and freeing the variables before using strdup Change-Id: I36d64d12d3a1568123549874571a35c9ecd0cda0 --- diff --git a/common/ma_config_mgr.c b/common/ma_config_mgr.c index 2b2c38c..ff4c5f6 100644 --- a/common/ma_config_mgr.c +++ b/common/ma_config_mgr.c @@ -139,6 +139,10 @@ int ma_config_mgr_parse_assistant_info(ma_ui_assistant_info_cb callback, void* u } else if (cur->name && 0 == xmlStrcmp(cur->name, (const xmlChar*)MA_TAG_ASSISTANT_NAME)) { key = xmlNodeGetContent(cur); if (key) { + if (temp->name) { + free((void*)temp->name); + temp->name = NULL; + } temp->name = strdup((const char*)key); MA_SLOGD("Name : %s", key); xmlFree(key); @@ -146,6 +150,10 @@ int ma_config_mgr_parse_assistant_info(ma_ui_assistant_info_cb callback, void* u } else if (cur->name && 0 == xmlStrcmp(cur->name, (const xmlChar*)MA_TAG_ASSISTANT_APPID)) { key = xmlNodeGetContent(cur); if (key) { + if (temp->app_id) { + free((void*)temp->app_id); + temp->app_id = NULL; + } temp->app_id = strdup((const char*)key); MA_SLOGD("ID : %s", key); xmlFree(key); @@ -153,6 +161,10 @@ int ma_config_mgr_parse_assistant_info(ma_ui_assistant_info_cb callback, void* u } else if (cur->name && 0 == xmlStrcmp(cur->name, (const xmlChar*)MA_TAG_ASSISTANT_ICON_PATH)) { key = xmlNodeGetContent(cur); if (key) { + if (temp->icon_path) { + free((void*)temp->icon_path); + temp->icon_path = NULL; + } temp->icon_path = strdup((const char*)key); MA_SLOGD("Icon Path : %s", key); xmlFree(key);