summaryrefslogtreecommitdiff
path: root/sway/ipc-server.c
diff options
context:
space:
mode:
authorKevin Hamacher <[email protected]>2015-12-14 11:43:17 +0100
committerKevin Hamacher <[email protected]>2015-12-14 11:43:17 +0100
commit64a183b23d2a0b2e628f641345e33d7ea46c0d07 (patch)
tree6afaf5b52ea1542d5068d7cc6a12b63dc236a95c /sway/ipc-server.c
parent93ac7d43a8e4a3822d8008667caa356c8ee50664 (diff)
Fix dangling pointer on focus swap/describe WS
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r--sway/ipc-server.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 7c737307..3f02812d 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -455,7 +455,11 @@ void ipc_get_outputs_callback(swayc_t *container, void *data) {
void ipc_event_workspace(swayc_t *old, swayc_t *new) {
json_object *obj = json_object_new_object();
json_object_object_add(obj, "change", json_object_new_string("focus"));
- json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
+ if (old) {
+ json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
+ } else {
+ json_object_object_add(obj, "old", NULL);
+ }
json_object_object_add(obj, "current", ipc_json_describe_workspace(new));
const char *json_string = json_object_to_json_string(obj);