Fix unsafe code for security 31/276931/3
authorInHong Han <inhong1.han@samsung.com>
Tue, 28 Jun 2022 02:49:50 +0000 (11:49 +0900)
committerInHong Han <inhong1.han@samsung.com>
Tue, 28 Jun 2022 02:55:18 +0000 (11:55 +0900)
Change-Id: If703ccf00bd8da35867c5f00bfd3e0ab0c1fde0b

assistant-parser/src/ma_assistant_parser.c

index dc3971c18c1ab5a22514577b95e3c992a51c93e1..b9a7ab463b154fe0793bfa40339d1393b89bdc9c 100644 (file)
@@ -326,6 +326,11 @@ static void __insert_language_from_metadata(xmlNodePtr root, const char *languag
        xmlNodePtr languages_node = NULL;
        xmlNodePtr lang_node = NULL;
 
+       if (tmp_lang == NULL) {
+               LOGE("[ERROR] Fail to allocate memory");
+               return;
+       }
+
        languages_node = xmlNewNode(NULL, (const xmlChar*)MA_TAG_ASSISTANT_LANGUAGE_SET);
        if (languages_node) {
                lang = strsep(&tmp_lang, ",");
@@ -401,6 +406,11 @@ static void __insert_wakeup_engine_from_metadata(xmlNodePtr root, const char *wa
        xmlNodePtr wakeup_engines_node = NULL;
        xmlNodePtr wakeup_engine_node = NULL;
 
+       if (tmp_wakeup_engine == NULL) {
+               LOGE("[ERROR] Fail to allocate memory");
+               return;
+       }
+
        char* engine = NULL;
        wakeup_engines_node = xmlNewNode(NULL, (const xmlChar*)MA_TAG_ASSISTANT_WAKEUP_ENGINE_SET);
        if (wakeup_engines_node) {