From bf8de1c8afbe1fe97d22e0b6ea0ece8005f894c2 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 1 Dec 2020 12:47:50 +0900 Subject: [PATCH] Fix issue detected by static analysis tool Dynamic memory referenced by 'pref_str' was allocated at preference.c:1245 by calling function 'preference_get_string' at config.cpp:74 and lost at config.cpp:75. Change-Id: I5f7a6f24701a8e4730daeb24903f78fafd3c142f Signed-off-by: Jihoon Kim --- src/config.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index ecde389..2f05e35 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -72,8 +72,10 @@ void read_ise_config_string(const char *key, std::string &value) int ret; ret = preference_get_string(key, &pref_str); - if (ret == PREFERENCE_ERROR_NONE && pref_str) { - value.assign(pref_str, strlen(pref_str)); + if (pref_str) { + if (ret == PREFERENCE_ERROR_NONE) + value.assign(pref_str, strlen(pref_str)); + free(pref_str); } } -- 2.7.4