Fix memory leak in stc_plugin_monitor_initialize 10/236810/1 submit/tizen/20200623.015427
authorJaehyun Kim <jeik01.kim@samsung.com>
Mon, 22 Jun 2020 06:34:16 +0000 (15:34 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Mon, 22 Jun 2020 08:15:17 +0000 (17:15 +0900)
Variable system going out of scope leaks the memory it points to.

Change-Id: I9d2c5dc3cc3b951954e793cf3864f270810d846c
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
plugin/monitor/stc-plugin-monitor.c

index a26749f..7922b88 100755 (executable)
@@ -343,15 +343,15 @@ stc_error_e stc_plugin_monitor_initialize(stc_manager_stop_cb stop_cb)
 {
        __STC_LOG_FUNC_ENTER__;
 
+       ret_value_msg_if(stop_cb == NULL, STC_ERROR_INVALID_PARAMETER,
+                               "stop_cb callback is NULL");
+
        stc_system_s *system = MALLOC0(stc_system_s, 1);
        GIOChannel *gio = NULL;
 
        ret_value_msg_if(system == NULL, STC_ERROR_OUT_OF_MEMORY,
                                "stc_system_s malloc fail!");
 
-       ret_value_msg_if(stop_cb == NULL, STC_ERROR_INVALID_PARAMETER,
-                               "stop_cb callback is NULL");
-
        g_stop_cb = stop_cb;
 
        /* initializing current classid */