Fix defects detected by static analysis tool 44/256044/2 accepted/tizen/unified/20210330.111233 submit/tizen/20210330.042720
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 29 Mar 2021 02:02:10 +0000 (11:02 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 29 Mar 2021 02:22:26 +0000 (11:22 +0900)
Change-Id: I63d6070426e1782484ba683979e16e3eff4d06fe

src/service_config.cpp

index 2f2bc27..cdf1687 100644 (file)
@@ -311,20 +311,23 @@ int CServiceConfig::load_custom_wake_words(const char* app_id,
        preference_is_existing("custom_wakeup_languages", &existing);
        if (!existing) return -1;
 
-       char* value = NULL;
-       preference_get_string("custom_wakeup_words", &value);
-       if (NULL == value) return -1;
-       strncpy(wakeup_words, value, sizeof(wakeup_words) - 1);
+       char* custom_wakeup_words = NULL;
+       preference_get_string("custom_wakeup_words", &custom_wakeup_words);
+       if (NULL == custom_wakeup_words) return -1;
+       strncpy(wakeup_words, custom_wakeup_words, sizeof(wakeup_words) - 1);
        wakeup_words[sizeof(wakeup_words) - 1] = '\0';
        LOGD("Custom wakeup words loaded : %s", wakeup_words);
-       free(value);
+       free(custom_wakeup_words);
+       custom_wakeup_words = NULL;
 
-       preference_get_string("custom_wakeup_languages", &value);
-       if (NULL == value) return -1;
-       strncpy(wakeup_languages, value, sizeof(wakeup_languages) - 1);
+       char* custom_wakeup_languages = NULL;
+       preference_get_string("custom_wakeup_languages", &custom_wakeup_languages);
+       if (NULL == custom_wakeup_languages) return -1;
+       strncpy(wakeup_languages, custom_wakeup_languages, sizeof(wakeup_languages) - 1);
        wakeup_languages[sizeof(wakeup_languages) - 1] = '\0';
        LOGD("Custom wakeup languages loaded : %s", wakeup_languages);
-       free(value);
+       free(custom_wakeup_languages);
+       custom_wakeup_languages = NULL;
 
        char *word_start = wakeup_words;
        char *language_start = wakeup_languages;