Fix defects detected by static analysis tool 97/319097/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 4 Feb 2025 07:44:15 +0000 (16:44 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 4 Feb 2025 07:54:52 +0000 (16:54 +0900)
Change-Id: I8eb0076f7983f2ed4535096aef86d7f042a1e26b

src/main.cpp
src/service_config.cpp
wakeup-manager/src/wakeup_engine_manager.cpp

index 8b324580ee7c2340e5d63ff8ac58e37822e960aa..e91e58bfb95636f7c5ea91506b3557de8fcb8e84 100644 (file)
@@ -29,13 +29,23 @@ CServiceMain g_service_main{g_application_manager_aul, g_preference_manager_vcon
 static bool service_app_create(void *data)
 {
        LOGI("");
-       return g_service_main.app_create(data);
+       bool ret = false;
+       try {
+               ret = g_service_main.app_create(data);
+       } catch (std::exception &e) {
+               LOGE("Exception : %s", e.what());
+       }
+       return ret;
 }
 
 static void service_app_terminate(void *data)
 {
        LOGI("");
-       return g_service_main.app_terminate(data);
+       try {
+               g_service_main.app_terminate(data);
+       } catch (std::exception &e) {
+               LOGE("Exception : %s", e.what());
+       }
 }
 
 static void service_app_control(app_control_h app_control, void *data)
index 3cd38acf610706dd2a92c34e58459a4fc8e1dd0c..96d4c66c37a59227937eb791f6af0dae08bb6309 100644 (file)
@@ -110,6 +110,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_NAME)) {
                        key = xmlNodeGetContent(cur);
                        if (key) {
+                               if (temp.name) {
+                                       free((void*)(temp.name));
+                                       temp.name = NULL;
+                               }
                                temp.name = strdup((const char*)key);
                                MAS_LOGI("Name : %s", key);
                                xmlFree(key);
@@ -117,6 +121,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_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);
                                MAS_LOGI("ID : %s", key);
                                xmlFree(key);
@@ -125,7 +133,7 @@ int CServiceConfig::parse_assistant_info(service_config_assistant_info_cb callba
                        key = xmlNodeGetContent(cur);
                        if (key) {
                                if (temp.icon_path) {
-                                       free((void*)temp.icon_path);
+                                       free((void*)(temp.icon_path));
                                        temp.icon_path = NULL;
                                }
                                temp.icon_path = strdup((const char*)key);
index ee866a9947eebfb7a1604e22de89282cb14aa5ec..b21fd9294a1677ab444b1297d2aa6e695e51c6dc 100644 (file)
@@ -106,7 +106,11 @@ void CWakeupEngineManager::deinitialize()
        if (mStreamingThread.joinable()) {
                MWR_LOGD("mStreamingThread is joinable, trying join()");
                mStopStreamingThread.store(true);
-               mStreamingThread.join();
+               try {
+                       mStreamingThread.join();
+               } catch (std::exception &e) {
+                       MWR_LOGE("Exception : %s", e.what());
+               }
        }
        mStopStreamingThread.store(false);
 
@@ -555,7 +559,11 @@ void CWakeupEngineManager::stop_streaming_current_utterance_data()
                        mStreamingHistory.last_count_fetched.load(),
                        mStreamingHistory.last_audio_sent.load());
                mStopStreamingThread.store(true);
-               mStreamingThread.join();
+               try {
+                       mStreamingThread.join();
+               } catch (std::exception &e) {
+                       MWR_LOGE("Exception : %s", e.what());
+               }
        }
        mStopStreamingThread.store(false);
 }