From 5e9396c534508d24ea4b10bd6b12d30715f98fa4 Mon Sep 17 00:00:00 2001 From: jomui Date: Fri, 7 Jul 2017 11:07:44 +0900 Subject: [PATCH] fix crash when request user consent Signed-off-by: jomui Change-Id: Ifbd9fd2394b73e1d38025a39930929898b215798 --- src/here_api.cpp | 8 +++----- src/here_manager.cpp | 6 ------ src/here_userconsent.cpp | 6 ++++++ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/here_api.cpp b/src/here_api.cpp index 761ffeb..00ba53b 100644 --- a/src/here_api.cpp +++ b/src/here_api.cpp @@ -841,11 +841,9 @@ int HerePluginCaptureSnapshot(maps_view_h view, void **data, int HerePluginRequestUC(const char *provider, void *pCbFunc, void *user_data) { - if(!HereManager::GetHandler()->m_UserConsent) - HereManager::GetHandler()->m_UserConsent = new (std::nothrow) HereUserConsent(provider, pCbFunc, user_data); - - if (HereManager::GetHandler()->m_UserConsent) - return HereManager::GetHandler()->m_UserConsent->RequestUserConsent(); + HereUserConsent *m_UserConsent = new (std::nothrow) HereUserConsent(provider, pCbFunc, user_data); + if (m_UserConsent) + return m_UserConsent->RequestUserConsent(); else return HERE_ERROR_OUT_OF_MEMORY; } diff --git a/src/here_manager.cpp b/src/here_manager.cpp index 65591ae..4a58e43 100644 --- a/src/here_manager.cpp +++ b/src/here_manager.cpp @@ -50,16 +50,10 @@ HereManager::HereManager() m_hConnection = NULL; pthread_mutex_init(&m_mtxHereList, NULL); pthread_mutex_init(&g_mtxRef, NULL); - - m_UserConsent = NULL; } HereManager::~HereManager() { - if (m_UserConsent) { - delete m_UserConsent; - m_UserConsent = NULL; - } if (m_hConnection) { connection_unset_type_changed_cb(m_hConnection); diff --git a/src/here_userconsent.cpp b/src/here_userconsent.cpp index 6fbd916..706b639 100644 --- a/src/here_userconsent.cpp +++ b/src/here_userconsent.cpp @@ -33,6 +33,7 @@ static void UserConsentChangedCb(keynode_t *node EINA_UNUSED, void *user_data) if (!pUserConsent->m_pCbFunc) { MAPS_LOGD("m_pCbFunc and is NULL"); + delete pUserConsent; return; } @@ -49,6 +50,8 @@ static void UserConsentChangedCb(keynode_t *node EINA_UNUSED, void *user_data) else ((maps_service_request_user_consent_with_handle_cb)pUserConsent->m_pCbFunc)((bool)enabled, pUserConsent->m_pUserData); + delete pUserConsent; + MAPS_FUNC_EXIT } @@ -136,6 +139,7 @@ here_error_e HereUserConsent::RequestUserConsent() if (agreed != TRUE) { if (vconf_notify_key_changed(VCONFKEY_LOCATION_HEREMAPS_CONSENT, UserConsentChangedCb, this) < 0) { MAPS_LOGD("Unable to register a vconf changed cb to VCONFKEY_LOCATION_HEREMAPS_CONSENT"); + delete this; return HERE_ERROR_SERVICE_NOT_AVAILABLE; } isSetVconfCb = true; @@ -151,6 +155,8 @@ here_error_e HereUserConsent::RequestUserConsent() ((maps_service_request_user_consent_cb)m_pCbFunc)(TRUE, m_provider, m_pUserData); else ((maps_service_request_user_consent_with_handle_cb)m_pCbFunc)(TRUE, m_pUserData); + + delete this; } return HERE_ERROR_NONE; -- 2.34.1