diff options
author | Drew DeVault <[email protected]> | 2018-07-06 08:43:33 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2018-07-06 08:43:33 -0700 |
commit | 817e847749240a0c04756c37c88dc554efc56c9e (patch) | |
tree | ef2a716f8ea06ce8bdc63d1a682901b24e5bfcf0 /sway/ipc-server.c | |
parent | 55c54bb63b82ee75e1893b48b3ce18f7317c6199 (diff) | |
parent | b3c55dd909b070625c9bfcebcb89cb8463e2ffc9 (diff) |
Merge pull request #2206 from martinetd/leaks
Fix a bunch of leaks
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r-- | sway/ipc-server.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 8cfd9f26..abdaa237 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -64,6 +64,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { close(ipc_socket); unlink(ipc_sockaddr->sun_path); + while (ipc_client_list->length) { + struct ipc_client *client = ipc_client_list->items[0]; + ipc_client_disconnect(client); + } list_free(ipc_client_list); if (ipc_sockaddr) { @@ -479,10 +483,10 @@ void ipc_client_handle_command(struct ipc_client *client) { case IPC_COMMAND: { struct cmd_results *results = execute_command(buf, NULL); - const char *json = cmd_results_to_json(results); - char reply[256]; - int length = snprintf(reply, sizeof(reply), "%s", json); - client_valid = ipc_send_reply(client, reply, (uint32_t)length); + char *json = cmd_results_to_json(results); + int length = strlen(json); + client_valid = ipc_send_reply(client, json, (uint32_t)length); + free(json); free_cmd_results(results); goto exit_cleanup; } |