Fix issue detected by static analysis tool 42/281442/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 19 Sep 2022 04:59:39 +0000 (13:59 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 19 Sep 2022 05:00:01 +0000 (14:00 +0900)
Memory leak found in case that ret is false.

Change-Id: I1d04fe2184057b541c3c8b2c8fe6075e875f9560
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
scl/xml_parser_utils.cpp
scl/xml_parser_utils.h

index 5ec17c0760b54ca9e340405ebb2829652d6565a1..337fbb7f2df04f94abad65fc61f9f9a4c0882da4 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 b72faf27f635dc3c01292af3ca37d72ab887629d..87796860da29fbfd836ceca2af53f97e53d1c04d 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);