Fix memory leak problem 21/112521/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 1 Feb 2017 07:58:14 +0000 (16:58 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 1 Feb 2017 08:19:30 +0000 (17:19 +0900)
Change-Id: I4e7c8b6cfe3c8530a991dd4935e7c6924b667ef5

xmlresource/layout_parser.cpp
xmlresource/magnifier_configure_parser.cpp

index b170b39..6c11ccf 100644 (file)
@@ -441,6 +441,7 @@ LayoutParserImpl::parsing_layout_table(const vector<string> &vec_file) {
         PSclLayout cur_rec_layout = &(m_layout_table[layout_id]);
         parsing_layout_node(cur_node, cur_rec_layout, layout_id);
         cur_rec_layout->name = (sclchar*)strdup(it->c_str());
+        add_layout_string((xmlChar*)cur_rec_layout->name);
 
         xmlFreeDoc(doc);
     }
@@ -1282,6 +1283,7 @@ LayoutParserImpl::parsing_auto_popup_keys_record_node(
             for (int shift_loop = 0;shift_loop < SCL_SHIFT_STATE_MAX;shift_loop++) {
                 if ((shift_state == shift_loop || shift_state == -1)) {
                     xmlChar* key = xmlNodeGetContent(child_node);
+                    sclboolean need_free = TRUE;
                     if (key) {
                         if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"label")) {
                             sclboolean upper_created = FALSE;
@@ -1292,10 +1294,12 @@ LayoutParserImpl::parsing_auto_popup_keys_record_node(
                                     add_upper_string(upper);
                                     upper_created = TRUE;
                                     key = reinterpret_cast<xmlChar*>(upper);
+                                    need_free = FALSE;
                                 }
                             }
                             if (!upper_created) {
                                 add_key_string(key);
+                                need_free = FALSE;
                             }
                             cur_rec->autopopup_key_labels[shift_loop][autopopup_state] = (sclchar*)key;
                             /* If current key_value is NULL, let's just consider this label is the default key_value */
@@ -1305,9 +1309,14 @@ LayoutParserImpl::parsing_auto_popup_keys_record_node(
                         } else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"value")) {
                             cur_rec->autopopup_key_values[shift_loop][autopopup_state] = (sclchar*)key;
                             add_key_string(key);
+                            need_free = FALSE;
                         } else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"event")) {
                             cur_rec->autopopup_key_events[shift_loop][autopopup_state] = (sclulong)atoi((sclchar*)key);
                             add_key_string(key);
+                            need_free = FALSE;
+                        }
+                        if (need_free) {
+                            xmlFree(key);
                         }
                     }
                 }
index 7f21962..f1f6b93 100644 (file)
@@ -68,6 +68,12 @@ class MagnifierConfigureParserImpl {
             xmlFree(m_magnifier_configure.label_type);
             m_magnifier_configure.label_type = NULL;
         }
+        for (int loop = 0;loop < MAX_WND_DECORATOR;loop++) {
+            if (m_magnifier_configure.decoration_image_path[loop]) {
+                xmlFree(m_magnifier_configure.decoration_image_path[loop]);
+                m_magnifier_configure.decoration_image_path[loop] = NULL;
+            }
+        }
     }
 
     int parsing_magnifier_configure(const char* input_file) {