Skip to contentSkip to conversation

controld: fix memory leak

PATCH New Alexander Aring 1 participant 1 message Jun 23, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 controld: fix memory leak

Compile with -fsanitize=address unveils the following memory leak:

==1175==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 216 byte(s) in 3 object(s) allocated from:

    #0 0x7f0881809b17 in calloc (/lib64/libasan.so.6+0xaeb17)
    #1 0x55b3f110bc78 in send_protocol /builddir/devel/dlm/dlm_controld/daemon_cpg.c:1872

SUMMARY: AddressSanitizer: 216 byte(s) leaked in 3 allocation(s).

This patch free's the allocated buffer in send_protocol which should be copied in a different buffer by _send_message() already.

---
 dlm_controld/daemon_cpg.c | 1 +
 1 file changed, 1 insertion(+)
dlm_controld/daemon_cpg.c +1 -0
index f215edfd..e6a03a28 100644
@@ -1886,6 +1886,7 @@ static void send_protocol(struct protocol *proto)
 	protocol_out(pr);
 
 	_send_message(cpg_handle_daemon, buf, len, DLM_MSG_PROTOCOL);
+	free(buf);
 }
 
 int set_protocol(void)
Signature · 1 line
2.31.1