From a968a650e26b9f6bba134ee8dfa9865e958c29da Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Thu, 21 Feb 2019 08:36:58 +0100 Subject: [PATCH 1/2] ipc-client: free payload after sending it over the socket Fixes memory leaks in the form of: Direct leak of 20 byte(s) in 1 object(s) allocated from: #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30) #1 0x563c7995b36a in join_args ../common/stringop.c:268 #2 0x563c798a6a1a in main ../sway/main.c:348 #3 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) --- sway/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sway/main.c b/sway/main.c index b118a182..5a65e50c 100644 --- a/sway/main.c +++ b/sway/main.c @@ -347,6 +347,7 @@ int main(int argc, char **argv) { } char *command = join_args(argv + optind, argc - optind); run_as_ipc_client(command, socket_path); + free(command); return 0; } From aa4ccd845cf93ac2117b12083fed748f4c01e744 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Thu, 21 Feb 2019 08:37:23 +0100 Subject: [PATCH 2/2] run_as_ipc_client: free response after running the IPC command Fixes memory leaks in the form of: Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30) #1 0x563c799569f2 in ipc_recv_response ../common/ipc-client.c:94 #2 0x563c79957062 in ipc_single_command ../common/ipc-client.c:138 #3 0x563c798a56cc in run_as_ipc_client ../sway/main.c:127 #4 0x563c798a6a3a in main ../sway/main.c:349 #5 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) --- sway/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sway/main.c b/sway/main.c index 5a65e50c..6754190f 100644 --- a/sway/main.c +++ b/sway/main.c @@ -126,6 +126,7 @@ void run_as_ipc_client(char *command, char *socket_path) { uint32_t len = strlen(command); char *resp = ipc_single_command(socketfd, IPC_COMMAND, command, &len); printf("%s\n", resp); + free(resp); close(socketfd); }