From: Jihoon Kim Date: Mon, 19 Sep 2022 04:59:39 +0000 (+0900) Subject: Fix issue detected by static analysis tool X-Git-Tag: accepted/tizen/unified/20220920.110643~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b60880099e3d3f92558824a29abcbf1f3c6b040;p=platform%2Fcore%2Fuifw%2Flibscl-ui-nui.git Fix issue detected by static analysis tool Memory leak found in case that ret is false. Change-Id: I1d04fe2184057b541c3c8b2c8fe6075e875f9560 Signed-off-by: Jihoon Kim --- diff --git a/scl/xml_parser_utils.cpp b/scl/xml_parser_utils.cpp index 5ec17c0..337fbb7 100644 --- a/scl/xml_parser_utils.cpp +++ b/scl/xml_parser_utils.cpp @@ -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; } diff --git a/scl/xml_parser_utils.h b/scl/xml_parser_utils.h index b72faf2..8779686 100644 --- a/scl/xml_parser_utils.h +++ b/scl/xml_parser_utils.h @@ -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);