From: Kiseok Chang Date: Tue, 15 Dec 2020 06:51:58 +0000 (+0900) Subject: Fix Memory leak X-Git-Tag: submit/tizen/20201216.014133^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d7e9422b005c45516ca147ad37d11b8d51934ed;p=profile%2Fcommon%2Fapps%2Fnative%2Fsettings.git Fix Memory leak - free mem allocated in app_control_get_extra_data() Change-Id: I667c10c34477778dd42f62bb2bc84f6ece4e2d9f Signed-off-by: Kiseok Chang --- diff --git a/setting-appmgr/src/setting-appmgr.c b/setting-appmgr/src/setting-appmgr.c index b86e33b..a92e3c7 100755 --- a/setting-appmgr/src/setting-appmgr.c +++ b/setting-appmgr/src/setting-appmgr.c @@ -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; } diff --git a/setting-time/src/setting-time-main.c b/setting-time/src/setting-time-main.c index 891e336..9694ef6 100755 --- a/setting-time/src/setting-time-main.c +++ b/setting-time/src/setting-time-main.c @@ -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; }