mirror of
https://github.com/swaywm/sway.git
synced 2026-03-30 11:10:59 -04:00
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.
This commit is contained in:
parent
c6e12368a5
commit
8272a9bae0
1 changed files with 2 additions and 1 deletions
|
|
@ -1126,7 +1126,8 @@ static void ipc_event_binding(json_object *sb_obj) {
|
||||||
sway_log(L_DEBUG, "Sending binding::run event");
|
sway_log(L_DEBUG, "Sending binding::run event");
|
||||||
json_object *obj = json_object_new_object();
|
json_object *obj = json_object_new_object();
|
||||||
json_object_object_add(obj, "change", json_object_new_string("run"));
|
json_object_object_add(obj, "change", json_object_new_string("run"));
|
||||||
json_object_object_add(obj, "binding", sb_obj);
|
// sb_obj gets owned by the temporary json_object, too.
|
||||||
|
json_object_object_add(obj, "binding", json_object_get(sb_obj));
|
||||||
|
|
||||||
const char *json_string = json_object_to_json_string(obj);
|
const char *json_string = json_object_to_json_string(obj);
|
||||||
ipc_send_event(json_string, IPC_EVENT_BINDING);
|
ipc_send_event(json_string, IPC_EVENT_BINDING);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue