Ensure wm_subscribe returns the correct value 09/23609/1 sandbox/KazumasaTanaka/change_screen_updated_test2 8.99.5 icefish/8.99.5 icefish_8.99.5
authorJose Bollo <jose.bollo@iot.bzh>
Wed, 22 Jan 2020 09:05:23 +0000 (10:05 +0100)
committerJose Bollo <jose.bollo@iot.bzh>
Wed, 22 Jan 2020 09:05:23 +0000 (10:05 +0100)
Also fix a memory leak.

Bug-AGL: SPEC-3116

Change-Id: Id4c51770d06f8984b60b9b25f13d6dcf5616b2ad
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
src/window_manager.cpp

index dcaf636..7fc47c3 100644 (file)
@@ -493,6 +493,7 @@ bool WindowManager::api_subscribe(afb_req_t req, EventType event_id)
     if(event_id < Event_Val_Min || event_id > Event_Val_Max)
     {
         HMI_ERROR("not defined in Window Manager", event_id);
+        free(appid);
         return ret;
     }
     HMI_INFO("%s subscribe %s : %d", appid, kListEventName[event_id].c_str(), event_id);
@@ -509,17 +510,17 @@ bool WindowManager::api_subscribe(afb_req_t req, EventType event_id)
     else if(appid)
     {
         string id = appid;
-        free(appid);
         if(!g_app_list.contains(id))
         {
             g_app_list.addClient(id);
         }
-        g_app_list.lookUpClient(id)->subscribe(req, kListEventName[event_id]);
+        ret = g_app_list.lookUpClient(id)->subscribe(req, kListEventName[event_id]);
     }
     else
     {
         HMI_ERROR("appid is not set");
     }
+    free(appid);
     return ret;
 }