From: Youngjae Shin Date: Tue, 24 Mar 2020 03:14:25 +0000 (+0900) Subject: fix memory leak X-Git-Tag: submit/tizen/20200324.035544~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4580c37d8057938cb1361ded2dcf5a2d63bbd8b4;p=platform%2Fcore%2Fsystem%2Fmodes.git fix memory leak --- diff --git a/plugin/TestPlugin.cpp b/plugin/TestPlugin.cpp index 7f370f6..fd65120 100644 --- a/plugin/TestPlugin.cpp +++ b/plugin/TestPlugin.cpp @@ -41,8 +41,11 @@ public: private: static gboolean changeTimeout(gpointer data) { + RETV_IF(nullptr == data, G_SOURCE_REMOVE); + TestPluginAction *testAction = (TestPluginAction*)data; testAction->callChangedCB(); + return G_SOURCE_REMOVE; } }; @@ -88,10 +91,12 @@ int TestPlugin::set(const std::string &key, int val, PluginAction **piAction) DBG("set(%s, %d)", key.c_str(), val); return MODES_ERROR_SYSTEM; } else if ("changeTime" == key) { - g_timeout_add_seconds(val, changeTimeout, (void*)testAction); + if (piAction) + g_timeout_add_seconds(val, changeTimeout, (void*)testAction); DBG("set(%s, %d)", key.c_str(), val); } else { ERR("Unknown key(%s)", key.c_str()); + delete testAction; return MODES_ERROR_NOT_SUPPORTED; }