summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-07-26 19:26:46 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-07-27 01:41:25 +0000
commit58f6609308a7fdf1035d1fd65c644febc862b122 (patch)
tree102538c74e4bd7b138f3ad23e00669cedeed1d99
parent478ad89b8da9d5bc68755433cab4963b7d0c8b96 (diff)
Fix not to release json_object on Event(Reply)
libafbwsc releases json_object on behalf of application. Then calling json_object in this library may cause double free, so fix it. Bug-AGL: SPEC-1471 Change-Id: I1bb3109c80891718f7bfd69e67688c1c880e95de Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/libhomescreen.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp
index 66fd259..f0e61b0 100644
--- a/src/libhomescreen.cpp
+++ b/src/libhomescreen.cpp
@@ -175,7 +175,7 @@ int LibHomeScreen::initialize_websocket()
/* Initialize interface from websocket */
minterface.on_hangup = _on_hangup_static;
- minterface.on_call = _on_call_static; /* Is this necessary? */
+ minterface.on_call = _on_call_static;
minterface.on_event = _on_event_static;
muri += "ws://localhost:" + to_string(mport) + "/api?token=" + mtoken; /*To be modified*/
sp_websock = afb_ws_client_connect_wsj1(mploop, muri.c_str(), &minterface, this);
@@ -280,6 +280,10 @@ int LibHomeScreen::onScreenReply(const char* reply_message)
*
* #### Return
* Nothing
+ *
+ * #### Note
+ * Don't release json_object by json_object_put in handler_func.
+ * The resource is released by libafbwsc library.
*/
void LibHomeScreen::set_event_handler(enum EventType et, handler_func f)
{
@@ -486,8 +490,6 @@ void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_m
i->second(json_data);
}
}
-
- json_object_put(ev_contents);
}
/**
@@ -501,8 +503,6 @@ void LibHomeScreen::on_reply(void *closure, struct afb_wsj1_msg *msg)
{
struct json_object* reply = afb_wsj1_msg_object_j(msg);
onReply(reply);
-
- json_object_put(reply);
}
}