From: Youngman Date: Mon, 14 Oct 2019 02:31:36 +0000 (+0900) Subject: Fix resource leaks when setting locale X-Git-Tag: submit/tizen/20191014.062557^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c20ea049ee46381b2a20fc12fa3aa32f0e24b0a3;p=platform%2Fcore%2Fsecurity%2Fprivacy-guard.git Fix resource leaks when setting locale Change-Id: Iaceca961e7f15aaa1a9936070ccff9eb3ff02439 --- diff --git a/server/src/service/DlpPrivacyInfoData.cpp b/server/src/service/DlpPrivacyInfoData.cpp index ef96005..fce7602 100644 --- a/server/src/service/DlpPrivacyInfoData.cpp +++ b/server/src/service/DlpPrivacyInfoData.cpp @@ -46,7 +46,9 @@ DlpPrivacyInfoData *DlpPrivacyInfoData::m_pInstance = NULL; DlpPrivacyInfoData::DlpPrivacyInfoData() : m_connection(NULL), m_locmgr(NULL), m_myprofile_watch(false) { - wifi_manager_initialize(&m_wifi_manager); + int ret = wifi_manager_initialize(&m_wifi_manager); + if (ret < 0) + PG_LOGE("wifi_manager_initialize() failed. Error=%d", ret); m_last_latitude = 0; m_last_longitude = 0; @@ -574,13 +576,16 @@ void DlpPrivacyInfoData::localeChanged(keynode_t *key, void *user_data) { DlpPrivacyInfoData *pid = (DlpPrivacyInfoData *) user_data; - const char *locale; + char *locale; char buffer[18]; // Setting program's locale based on system settings locale = vconf_get_str(VCONFKEY_LANGSET); - if (locale) + if (locale) { setlocale(LC_ALL, locale); + free(locale); + locale = NULL; + } if (pid->m_owner_ibirthday == 0) return; @@ -603,12 +608,15 @@ DlpPrivacyInfoData::start(void) { pthread_t locmgr_thread; int ret; - const char *locale; + char *locale; // Setting program's locale based on system settings locale = vconf_get_str(VCONFKEY_LANGSET); - if (locale) + if (locale) { setlocale(LC_ALL, locale); + free(locale); + locale = NULL; + } vconf_notify_key_changed(VCONFKEY_LANGSET, localeChanged, this);