aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-10-15 19:58:51 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-10-18 09:34:18 +0900
commit6a20800629fca350b00ce71a09ba4d71e2f2ee1d (patch)
tree4b464f91af2523155f43db05e73f75289a3f8432
parent263fd00842589a5c7d9106c59fd31bbfcbcce4fe (diff)
According to afb_x2_req.h, returned value of afb_req_x2_get_application_id must be freed by the caller. So release it when the function returned not Null. cherry-picked from master Bug-AGL: SPEC-1819 Change-Id: I4f23eeff6262171ac55776b4e214960dbff7ff45 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/main.cpp117
1 files changed, 71 insertions, 46 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0447f86..e6cccb5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -236,18 +236,26 @@ void windowmanager_requestsurface(afb_req req) noexcept
return;
}
- const char *appid = afb_req_get_application_id(req);
- auto ret = g_afb_instance->wmgr.api_request_surface(
- appid, a_drawing_name);
- if (ret.is_err())
+ char *appid = afb_req_get_application_id(req);
+ if(appid)
{
- afb_req_fail(req, "failed", ret.unwrap_err());
- return;
+ auto ret = g_afb_instance->wmgr.api_request_surface(
+ appid, a_drawing_name);
+ if (ret.is_err())
+ {
+ afb_req_fail(req, "failed", ret.unwrap_err());
+ }
+ else
+ {
+ createSecurityContext(req, appid, a_drawing_name);
+ afb_req_success(req, json_object_new_int(ret.unwrap()), "success");
+ }
+ free(appid);
+ }
+ else
+ {
+ afb_req_fail(req, "failed", nullptr);
}
-
- createSecurityContext(req, appid, a_drawing_name);
-
- afb_req_success(req, json_object_new_int(ret.unwrap()), "success");
}
catch (std::exception &e)
{
@@ -287,19 +295,23 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept
return;
}
char const *a_ivi_id = json_object_get_string(j_ivi_id);
- char const *appid = afb_req_get_application_id(req);
- auto ret = g_afb_instance->wmgr.api_request_surface(
- appid, a_drawing_name, a_ivi_id);
-
- if (ret != nullptr)
+ char *appid = afb_req_get_application_id(req);
+ if(appid)
{
- afb_req_fail(req, "failed", ret);
- return;
- }
-
- createSecurityContext(req, appid, a_drawing_name);
+ auto ret = g_afb_instance->wmgr.api_request_surface(
+ appid, a_drawing_name, a_ivi_id);
- afb_req_success(req, NULL, "success");
+ if (ret != nullptr)
+ {
+ afb_req_fail(req, "failed", ret);
+ }
+ else
+ {
+ createSecurityContext(req, appid, a_drawing_name);
+ afb_req_success(req, NULL, "success");
+ }
+ free(appid);
+ }
}
catch (std::exception &e)
{
@@ -336,18 +348,22 @@ void windowmanager_activatewindow(afb_req req) noexcept
return;
}
- g_afb_instance->wmgr.api_activate_surface(
- afb_req_get_application_id(req),
- a_drawing_name, a_drawing_area,
- [&req](const char *errmsg) {
- if (errmsg != nullptr)
- {
- HMI_ERROR("wm", errmsg);
- afb_req_fail(req, "failed", errmsg);
- return;
- }
- afb_req_success(req, NULL, "success");
- });
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ g_afb_instance->wmgr.api_activate_surface(
+ appid, a_drawing_name, a_drawing_area,
+ [&req](const char *errmsg) {
+ if (errmsg != nullptr)
+ {
+ HMI_ERROR("wm", errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ });
+ free(appid);
+ }
}
catch (std::exception &e)
{
@@ -378,17 +394,22 @@ void windowmanager_deactivatewindow(afb_req req) noexcept
return;
}
- g_afb_instance->wmgr.api_deactivate_surface(
- afb_req_get_application_id(req), a_drawing_name,
- [&req](const char *errmsg) {
- if (errmsg != nullptr)
- {
- HMI_ERROR("wm", errmsg);
- afb_req_fail(req, "failed", errmsg);
- return;
- }
- afb_req_success(req, NULL, "success");
- });
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ g_afb_instance->wmgr.api_deactivate_surface(
+ appid, a_drawing_name,
+ [&req](const char *errmsg) {
+ if (errmsg != nullptr)
+ {
+ HMI_ERROR("wm", errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ });
+ free(appid);
+ }
}
catch (std::exception &e)
{
@@ -420,8 +441,12 @@ void windowmanager_enddraw(afb_req req) noexcept
}
afb_req_success(req, NULL, "success");
- g_afb_instance->wmgr.api_enddraw(
- afb_req_get_application_id(req), a_drawing_name);
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ g_afb_instance->wmgr.api_enddraw(appid, a_drawing_name);
+ free(appid);
+ }
}
catch (std::exception &e)
{