fix crash when request user consent 25/137625/3 accepted/tizen/unified/20170710.154411 submit/tizen/20170707.034332 submit/tizen/20170709.232333
authorjomui <jongmun.woo@samsung.com>
Fri, 7 Jul 2017 02:07:44 +0000 (11:07 +0900)
committerjomui <jongmun.woo@samsung.com>
Fri, 7 Jul 2017 03:40:15 +0000 (12:40 +0900)
Signed-off-by: jomui <jongmun.woo@samsung.com>
Change-Id: Ifbd9fd2394b73e1d38025a39930929898b215798

src/here_api.cpp
src/here_manager.cpp
src/here_userconsent.cpp

index 761ffeb..00ba53b 100644 (file)
@@ -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;
 }
index 65591ae..4a58e43 100644 (file)
@@ -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);
index 6fbd916..706b639 100644 (file)
@@ -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;