Fix memory leak 99/123399/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Tue, 28 Feb 2017 02:36:27 +0000 (11:36 +0900)
committerKwangyoun Kim <ky85.kim@samsung.com>
Wed, 5 Apr 2017 10:23:30 +0000 (03:23 -0700)
Change-Id: I18ba097995369132ce37182ea1121a4a9f904b08
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
(cherry picked from commit 879a3f9b820e75af645d4a12d10b9df0c969d84c)

common/stt_config_parser.c

index 083d657..aba6692 100644 (file)
@@ -896,6 +896,20 @@ int stt_parser_set_time_info(GSList* time_list)
        return 0;
 }
 
+void __stt_parser_time_info_free(void* data)
+{
+       stt_result_time_info_s* time_info = (stt_result_time_info_s*)data;
+
+       if (NULL != time_info) {
+               if (NULL != time_info->text) {
+                       free(time_info->text);
+                       time_info->text = NULL;
+               }
+
+               free(time_info);
+       }
+}
+
 int stt_parser_get_time_info(GSList** time_list)
 {
        if (NULL == time_list) {
@@ -942,6 +956,11 @@ int stt_parser_get_time_info(GSList** time_list)
                        key = xmlGetProp(cur, (const xmlChar*)STT_TAG_TIME_COUNT);
                        if (NULL == key) {
                                SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_COUNT);
+
+                               if (NULL != temp_time_list) {
+                                       g_slist_free_full(temp_time_list, __stt_parser_time_info_free);
+                                       temp_time_list = NULL;
+                               }
                                xmlFreeDoc(doc);
                                return -1;
                        }
@@ -973,7 +992,7 @@ int stt_parser_get_time_info(GSList** time_list)
                                        SLOG(LOG_ERROR, stt_tag(), "[ERROR] Memory alloc error!!");
 
                                        if (NULL != temp_time_list) {
-                                               g_slist_free_full(temp_time_list, free);
+                                               g_slist_free_full(temp_time_list, __stt_parser_time_info_free);
                                                temp_time_list = NULL;
                                        }
                                        xmlFreeDoc(doc);