diff options
author | Björn Esser <besser82@fedoraproject.org> | 2017-12-14 01:30:54 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-12-17 15:53:22 -0500 |
commit | c08c805ecd8f2000a35cdeae7b16244d0b3c0528 (patch) | |
tree | 8a1a12a32a1d2c40bc4fdb43aa7205362438f65b /sway | |
parent | Revert "Merge remote-tracking branch 'besser82/bugfix/json-c' into 0.15" (diff) | |
download | sway-c08c805ecd8f2000a35cdeae7b16244d0b3c0528.tar.gz sway-c08c805ecd8f2000a35cdeae7b16244d0b3c0528.tar.zst sway-c08c805ecd8f2000a35cdeae7b16244d0b3c0528.zip |
Adaptions for API change in json-c v0.130.15.1
Lift restriction on json-c <= 0.12.1
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.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/ipc-server.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index b560b930..e10445cf 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <stdlib.h> | 15 | #include <stdlib.h> |
16 | #include <sys/ioctl.h> | 16 | #include <sys/ioctl.h> |
17 | #include <fcntl.h> | 17 | #include <fcntl.h> |
18 | #include <json-c/json.h> | ||
19 | #include <list.h> | 18 | #include <list.h> |
20 | #include <libinput.h> | 19 | #include <libinput.h> |
21 | #ifdef __linux__ | 20 | #ifdef __linux__ |
@@ -25,6 +24,7 @@ struct ucred { | |||
25 | gid_t gid; | 24 | gid_t gid; |
26 | }; | 25 | }; |
27 | #endif | 26 | #endif |
27 | #include "sway_json_helper.h" | ||
28 | #include "sway/ipc-json.h" | 28 | #include "sway/ipc-json.h" |
29 | #include "sway/ipc-server.h" | 29 | #include "sway/ipc-server.h" |
30 | #include "sway/security.h" | 30 | #include "sway/security.h" |
@@ -724,7 +724,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
724 | } | 724 | } |
725 | 725 | ||
726 | // parse requested event types | 726 | // parse requested event types |
727 | for (int i = 0; i < json_object_array_length(request); i++) { | 727 | for (json_ar_len_t i = 0; i < json_object_array_length(request); i++) { |
728 | const char *event_type = json_object_get_string(json_object_array_get_idx(request, i)); | 728 | const char *event_type = json_object_get_string(json_object_array_get_idx(request, i)); |
729 | if (strcmp(event_type, "workspace") == 0) { | 729 | if (strcmp(event_type, "workspace") == 0) { |
730 | client->subscribed_events |= event_mask(IPC_EVENT_WORKSPACE); | 730 | client->subscribed_events |= event_mask(IPC_EVENT_WORKSPACE); |
@@ -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); |