Fix defects detected by static analysis tool 54/214354/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 20 Sep 2019 11:50:29 +0000 (20:50 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Fri, 20 Sep 2019 11:50:29 +0000 (20:50 +0900)
Change-Id: Ia6e40f9bef97c20b127393587d4ed3c268e18d6e

src/multi_assistant_service.c

index c05726d2b1e553491568ddbd6f2c42c279869d02..773cb7d760be00af2bbbd3d8a0173e9824a7f95c 100644 (file)
@@ -455,8 +455,12 @@ int mas_client_set_preprocessing_allow_mode(int pid, int mode, const char* appid
                if (g_maclient_info[loop].used) {
                        if (pid_appid && strncmp(pid_appid, g_maclient_info[loop].appid, MAX_APPID_LEN) == 0) {
                                g_maclient_info[loop].preprocessing_allow_mode = mode;
-                               strncpy(g_maclient_info[loop].preprocessing_allow_appid, appid, MAX_APPID_LEN);
-                               g_maclient_info[loop].preprocessing_allow_appid[MAX_APPID_LEN - 1] = '\0';
+                               if (appid) {
+                                       strncpy(g_maclient_info[loop].preprocessing_allow_appid, appid, MAX_APPID_LEN);
+                                       g_maclient_info[loop].preprocessing_allow_appid[MAX_APPID_LEN - 1] = '\0';
+                               } else {
+                                       g_maclient_info[loop].preprocessing_allow_appid[0] = '\0';
+                               }
                        }
                }
        }
@@ -1018,7 +1022,7 @@ int mas_process_voice_key_event(bool pressed)
 ma_preprocessing_allow_mode_e get_preprocessing_allow_mode(const char* appid)
 {
        for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
-               if (g_maclient_info[loop].used) {
+               if (appid && g_maclient_info[loop].used) {
                        if (strncmp(appid, g_maclient_info[loop].appid, MAX_APPID_LEN) == 0) {
                                return g_maclient_info[loop].preprocessing_allow_mode;
                        }