From c20ea049ee46381b2a20fc12fa3aa32f0e24b0a3 Mon Sep 17 00:00:00 2001 From: Youngman Date: Mon, 14 Oct 2019 11:31:36 +0900 Subject: [PATCH] Fix resource leaks when setting locale Change-Id: Iaceca961e7f15aaa1a9936070ccff9eb3ff02439 --- server/src/service/DlpPrivacyInfoData.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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); -- 2.7.4