From 5d3a004c71191fd365647aae3ceb5d46813187e1 Mon Sep 17 00:00:00 2001 From: "s414.kim" Date: Thu, 29 Aug 2019 18:32:10 +0900 Subject: [PATCH] Fix resource leaks Change-Id: I9b15df8b4f5873416eb6ec362ad56e60a74c7ed9 Signed-off-by: s414.kim Signed-off-by: Sangwan Kwon --- ode/src/interface/tools/vconf.cpp | 9 +++++++-- ode/src/interface/tools/vconf.h | 4 +++- secure-erase/src/ui.c | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ode/src/interface/tools/vconf.cpp b/ode/src/interface/tools/vconf.cpp index 2c1fe3b..05af81e 100644 --- a/ode/src/interface/tools/vconf.cpp +++ b/ode/src/interface/tools/vconf.cpp @@ -18,6 +18,8 @@ #include "vconf.h" +#include + static void keyChangedCallback(keynode_t *node, void *data) { Vconf *vconf = reinterpret_cast(data); @@ -33,9 +35,12 @@ Vconf::~Vconf() { } -char *Vconf::getString() +std::string Vconf::getString() { - return ::vconf_get_str(vconfKey.c_str()); + char *tmp = ::vconf_get_str(vconfKey.c_str()); + std::string ret = (tmp != nullptr) ? std::string(tmp) : std::string(); + ::free(tmp); + return ret; } int Vconf::getInt() diff --git a/ode/src/interface/tools/vconf.h b/ode/src/interface/tools/vconf.h index 680fcea..0e3b614 100644 --- a/ode/src/interface/tools/vconf.h +++ b/ode/src/interface/tools/vconf.h @@ -19,6 +19,8 @@ #ifndef __ODE_VCONF_H__ #define __ODE_VCONF_H__ +#include + #include #include "../../widgets/signal.h" @@ -27,7 +29,7 @@ public: Vconf(const std::string &key); ~Vconf(); - char *getString(); + std::string getString(); int getInt(); bool getBool(); diff --git a/secure-erase/src/ui.c b/secure-erase/src/ui.c index 6cf2fa3..f18b405 100644 --- a/secure-erase/src/ui.c +++ b/secure-erase/src/ui.c @@ -109,6 +109,7 @@ static Eina_Bool progressbar_timer_cb(void *data) progress = vconf_get_str(VCONFKEY_ODE_ERASE_PROGRESS); if (progress) { percentage = atoi(progress); + free(progress); } else { delete_notification(ud->notification); ui_app_exit(); -- 2.34.1