aboutsummaryrefslogtreecommitdiffstats
path: root/sway/ipc-server.c
diff options
context:
space:
mode:
authorLibravatar Dominique Martinet <asmadeus@codewreck.org>2018-06-30 17:02:23 +0900
committerLibravatar Dominique Martinet <asmadeus@codewreck.org>2018-07-02 08:03:41 +0900
commit546ddbcd5bd76def3bb51114d4e1e6eb93eb16e7 (patch)
tree6de9a85cd3c327e73a5772e23c56e2f801494088 /sway/ipc-server.c
parentinvoke_swaybar: fix message length header size (diff)
downloadsway-546ddbcd5bd76def3bb51114d4e1e6eb93eb16e7.tar.gz
sway-546ddbcd5bd76def3bb51114d4e1e6eb93eb16e7.tar.zst
sway-546ddbcd5bd76def3bb51114d4e1e6eb93eb16e7.zip
ipc-server: fix double-free on send error in ipc_send_event
ipc_send_reply already does client disconnect on error, so we shouldn't do it again. We also need to process current index again as disconnect removes client from the list we currently are processing (this is an indexed "list") Found through static analysis.
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r--sway/ipc-server.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 241fe742..ec933ec3 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -263,7 +263,10 @@ static void ipc_send_event(const char *json_string, enum ipc_command_type event)
263 client->current_command = event; 263 client->current_command = event;
264 if (!ipc_send_reply(client, json_string, (uint32_t) strlen(json_string))) { 264 if (!ipc_send_reply(client, json_string, (uint32_t) strlen(json_string))) {
265 wlr_log_errno(L_INFO, "Unable to send reply to IPC client"); 265 wlr_log_errno(L_INFO, "Unable to send reply to IPC client");
266 ipc_client_disconnect(client); 266 /* ipc_send_reply destroys client on error, which also
267 * removes it from the list, so we need to process
268 * current index again */
269 i--;
267 } 270 }
268 } 271 }
269} 272}