From b730d31a7e5e23756ab1b076de21d41369a500c5 Mon Sep 17 00:00:00 2001 From: wang_zhiqiang Date: Wed, 28 Nov 2018 17:23:49 +0800 Subject: fix issue,not free string After called afb_req_get_application_id api needed to free the string. Change-Id: Ia59a3f4984854d61f4c5a8d9206f44988594ebf3 Signed-off-by: wang_zhiqiang --- src/hs-clientmanager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/hs-clientmanager.cpp') diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp index ba29326..1355c99 100644 --- a/src/hs-clientmanager.cpp +++ b/src/hs-clientmanager.cpp @@ -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 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 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 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 lock(this->mtx); auto ip = client_list.find(appid); if(ip != client_list.end() && ip->second->unsubscribe(request, value) != 0) { -- cgit 1.2.3-korg