summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Björn Esser <besser82@fedoraproject.org>2017-12-14 16:44:18 +0100
committerLibravatar Björn Esser <besser82@fedoraproject.org>2017-12-14 18:47:22 +0100
commit8272a9bae0d288b479c517dde3e831ea3889dc7f (patch)
tree5fe480a432be22e3b7186f481bbaf159b6ccbca5
parentLift restriction on json-c <= 0.12.1 (diff)
downloadsway-8272a9bae0d288b479c517dde3e831ea3889dc7f.tar.gz
sway-8272a9bae0d288b479c517dde3e831ea3889dc7f.tar.zst
sway-8272a9bae0d288b479c517dde3e831ea3889dc7f.zip
ipc-server: Acquire ownership of referenced json_object properly
When adding a referenced json_object with an unknown lifetime to another json_object, it must be done with a wrapped call to json_object_get() to acquire the ownership of that json_object.
-rw-r--r--sway/ipc-server.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index b560b930..80f4e5d0 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -1126,7 +1126,8 @@ static void ipc_event_binding(json_object *sb_obj) {
1126 sway_log(L_DEBUG, "Sending binding::run event"); 1126 sway_log(L_DEBUG, "Sending binding::run event");
1127 json_object *obj = json_object_new_object(); 1127 json_object *obj = json_object_new_object();
1128 json_object_object_add(obj, "change", json_object_new_string("run")); 1128 json_object_object_add(obj, "change", json_object_new_string("run"));
1129 json_object_object_add(obj, "binding", sb_obj); 1129 // sb_obj gets owned by the temporary json_object, too.
1130 json_object_object_add(obj, "binding", json_object_get(sb_obj));
1130 1131
1131 const char *json_string = json_object_to_json_string(obj); 1132 const char *json_string = json_object_to_json_string(obj);
1132 ipc_send_event(json_string, IPC_EVENT_BINDING); 1133 ipc_send_event(json_string, IPC_EVENT_BINDING);