Fix issue detected by static analysis tool 47/281447/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 19 Sep 2022 06:27:29 +0000 (15:27 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 19 Sep 2022 06:27:29 +0000 (15:27 +0900)
Memory leak found in case that ret is false.

Change-Id: I99bc47e878ca93e4b213e2f04ba366be24ae2b81

scl/xml_parser_utils.cpp
scl/xml_parser_utils.h

index 5ec17c0..337fbb7 100644 (file)
@@ -88,9 +88,11 @@ get_prop_bool(const xmlNodePtr cur_node, const char* prop, sclboolean *ret) {
         } else {
             *ret = false;
         }
-        xmlFree(key);
     }
 
+    if (key)
+        xmlFree(key);
+
     return succeeded;
 }
 
index b72faf2..8779686 100644 (file)
@@ -41,9 +41,11 @@ bool get_prop_number(const xmlNodePtr cur_node, const char* prop, T *ret) {
     if (ret && key != NULL) {
         succeeded = true;
         *ret = (T)atoi((const char*)key);
-        xmlFree(key);
     }
 
+    if (key)
+        xmlFree(key);
+
     return succeeded;
 }
 bool get_prop_bool(const xmlNodePtr cur_node, const char* prop, sclboolean *ret);