diff mbox series

[BlueZ,resend,5/9] obexd: Fix memory leak in entry struct

Message ID 20240702142436.833138-6-hadess@hadess.net
State Superseded
Headers show
Series Fix a number of static analysis issues #4 | expand

Commit Message

Bastien Nocera July 2, 2024, 2:23 p.m. UTC
recipient_addressing was never freed.

Error: RESOURCE_LEAK (CWE-772): [#def36] [important]
bluez-5.76/obexd/plugins/messages-dummy.c:379:4: alloc_fn: Storage is returned from allocation function "g_strdup_inline".
bluez-5.76/obexd/plugins/messages-dummy.c:379:4: var_assign: Assigning: "entry->recipient_addressing" = storage returned from "g_strdup_inline(values[i])".
bluez-5.76/obexd/plugins/messages-dummy.c:404:2: leaked_storage: Freeing "entry" without freeing its pointer field "recipient_addressing" leaks the storage that "recipient_addressing" points to.
402|	g_free(entry->attachment_size);
403|	g_free(entry->handle);
404|->	g_free(entry);
405|   }
406|
---
 obexd/plugins/messages-dummy.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c
index 92378dab4b20..e313c6163ec4 100644
--- a/obexd/plugins/messages-dummy.c
+++ b/obexd/plugins/messages-dummy.c
@@ -406,6 +406,7 @@  static void msg_element(GMarkupParseContext *ctxt, const char *element,
 	g_free(entry->reception_status);
 	g_free(entry->type);
 	g_free(entry->sender_addressing);
+	g_free(entry->recipient_addressing);
 	g_free(entry->subject);
 	g_free(entry->datetime);
 	g_free(entry->attachment_size);