Fix Memory leak 82/249582/3 accepted/tizen/unified/20201218.124456 submit/tizen/20201216.014133
authorKiseok Chang <kiso.chang@samsung.com>
Tue, 15 Dec 2020 06:51:58 +0000 (15:51 +0900)
committerKiseok Chang <kiso.chang@samsung.com>
Wed, 16 Dec 2020 01:02:38 +0000 (10:02 +0900)
- free mem allocated in app_control_get_extra_data()

Change-Id: I667c10c34477778dd42f62bb2bc84f6ece4e2d9f
Signed-off-by: Kiseok Chang <kiso.chang@samsung.com>
setting-appmgr/src/setting-appmgr.c
setting-time/src/setting-time-main.c

index b86e33b76d2540434483d090a31b18762d34dd4c..a92e3c7135126a4989641d36a5b1274d0f044ad4 100755 (executable)
@@ -141,6 +141,7 @@ static void _setting_appmgr_app_control_cb(app_control_h app_control,
                                                        ad->md.app_reply_svc,
                                                        ad->md.app_caller_svc,
                                                APP_CONTROL_RESULT_FAILED);
+                       free(viewtype);
                        ui_app_exit();
                        return;
                }
@@ -156,7 +157,7 @@ static void _setting_appmgr_app_control_cb(app_control_h app_control,
                                                        ad->md.app_reply_svc,
                                                        ad->md.app_caller_svc,
                                                APP_CONTROL_RESULT_FAILED);
-
+                       free(viewtype);
                        ui_app_exit();
                        return;
                }
@@ -173,7 +174,7 @@ static void _setting_appmgr_app_control_cb(app_control_h app_control,
                                                        ad->md.app_reply_svc,
                                                        ad->md.app_caller_svc,
                                                APP_CONTROL_RESULT_FAILED);
-
+                       free(viewtype);
                        ui_app_exit();
                        return;
                }
index 891e336a6c6163453660e28f88165e2b0c0f272a..9694ef68a47a584d9cadc57cd5785286f4cf71e6 100755 (executable)
@@ -1219,48 +1219,48 @@ static void _worldclock_reply_cb(app_control_h request, app_control_h reply,
 
        SettingTimeData *ad = (SettingTimeData *) user_data;
 
-       char *city = NULL;
        char *tzpath = NULL;
-       app_control_get_extra_data(reply, "city", &city);
        app_control_get_extra_data(reply, "tzpath", &tzpath);
-
        if (!tzpath) {
-               SETTING_TRACE("tzpath from worldclock UG is null.");
+               SETTING_TRACE_ERROR("tzpath from worldclock UG is null.");
                setting_update_timezone(ad);
                return;
-       } else {
-               SETTING_TRACE("tzpath : %s", tzpath);
        }
-       SETTING_TRACE("city : %s", city);
-
-       /* ----------------------------------------------------------------- */
-
        SETTING_TRACE("tzpath:(%s)", tzpath);
 
        int ret = _set_timezone_helper(tzpath);
        if (ret < 0) {
-               SETTING_TRACE("tzpath is not valid.");
-               if (tzpath)
-                       FREE(tzpath);
-               if (city)
-                       FREE(city);
+               SETTING_TRACE_ERROR("tzpath is not valid.");
+               free(tzpath);
                return;
-       } else
-               SETTING_TRACE("_set_timezone_helper - successful : "
+       }
+       SETTING_TRACE("_set_timezone_helper - successful : "
                                "%s \n", tzpath);
 
+       char *city = NULL;
+       app_control_get_extra_data(reply, "city", &city);
+       if (!city) {
+               SETTING_TRACE_ERROR("city from worldclock UG is null.");
+               free(tzpath);
+               return;
+       }
+       SETTING_TRACE("city : %s", city);
+
        ret = vconf_set_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT, city);
-       setting_retm_if(ret != 0, "set vconf failed");
+       if (ret != 0) {
+               SETTING_TRACE_ERROR("set vconf failed");
+               free(tzpath);
+               free(city);
+               return;
+       }
 
        /* parse city and GMT offset from tzpath and system time property */
        /* set the strings in vconf which will be used while updating display
         * of timezone */
        if (!__setting_set_city_tzone(tzpath)) {
-               SETTING_TRACE("__setting_set_city_tzone ERROR");
-               if (tzpath)
-                       FREE(tzpath);
-               if (city)
-                       FREE(city);
+               SETTING_TRACE_ERROR("__setting_set_city_tzone ERROR");
+               free(tzpath);
+               free(city);
                return;
        }
 
@@ -1268,10 +1268,8 @@ static void _worldclock_reply_cb(app_control_h request, app_control_h reply,
        setting_update_timezone(ad);
        static int t_event_val = 0;
        vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED, t_event_val);
-       if (tzpath)
-               FREE(tzpath);
-       if (city)
-               FREE(city);
+       free(tzpath);
+       free(city);
 
        SETTING_TRACE_END;
 }