fix issue,not free string
[apps/agl-service-homescreen.git] / src / hs-clientmanager.cpp
index ba29326..1355c99 100644 (file)
@@ -254,9 +254,13 @@ int HS_ClientManager::subscribe(afb_req_t request)
     const char *value = afb_req_value(request, "event");
     HMI_NOTICE("homescreen-service","value is %s", value);
     if(value) {
-        std::string appid(afb_req_get_application_id(request));
-        std::lock_guard<std::mutex> lock(this->mtx);
+        std::string appid =std::move(get_application_id(request));
+        if(appid.empty()) {
+            HMI_NOTICE("homescreen-service","can't get application identifier");
+            return AFB_REQ_GETAPPLICATIONID_ERROR;
+        }
 
+        std::lock_guard<std::mutex> lock(this->mtx);
         HS_Client* client = nullptr;
         auto ip = client_list.find(appid);
         if(ip != client_list.end()) {
@@ -295,9 +299,13 @@ int HS_ClientManager::unsubscribe(afb_req_t request)
     HMI_NOTICE("homescreen-service","value is %s", value);
     int ret = 0;
     if(value) {
-        std::string appid(afb_req_get_application_id(request));
-        std::lock_guard<std::mutex> lock(this->mtx);
+        std::string appid = std::move(get_application_id(request));
+        if(appid.empty()) {
+            HMI_NOTICE("homescreen-service","can't get application identifier");
+            return AFB_REQ_GETAPPLICATIONID_ERROR;
+        }
 
+        std::lock_guard<std::mutex> lock(this->mtx);
         auto ip = client_list.find(appid);
         if(ip != client_list.end()
         && ip->second->unsubscribe(request, value) != 0) {