Fix defects detected by coverity tool 80/319080/2
authordyamy-lee <dyamy.lee@samsung.com>
Tue, 4 Feb 2025 04:37:58 +0000 (13:37 +0900)
committerdyamy-lee <dyamy.lee@samsung.com>
Tue, 4 Feb 2025 05:05:58 +0000 (14:05 +0900)
To pervent memory leak, checking and freeing the variable before using strdup

Change-Id: I2c98f1f8dbedc17d8e9731b668ea3cd9ee021b2d

src/service_config.cpp

index 9741ccd7b6aa2675b1562a14bd7f4066e1da13c5..3cd38acf610706dd2a92c34e58459a4fc8e1dd0c 100644 (file)
@@ -124,6 +124,10 @@ int CServiceConfig::parse_assistant_info(service_config_assistant_info_cb callba
                } 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);
                                MAS_LOGI("Icon Path : %s", key);
                                xmlFree(key);