diff mbox series

[6/9] obexd: Fix leak in backup_object struct

Message ID 20240702084900.773620-7-hadess@hadess.net
State New
Headers show
Series Fix a number of static analysis issues #4 | expand

Commit Message

Bastien Nocera July 2, 2024, 8:47 a.m. UTC
Error: RESOURCE_LEAK (CWE-772): [#def37] [important]
bluez-5.76/obexd/plugins/pcsuite.c:370:2: alloc_fn: Storage is returned from allocation function "g_path_get_basename".
bluez-5.76/obexd/plugins/pcsuite.c:370:2: var_assign: Assigning: "obj->cmd" = storage returned from "g_path_get_basename(name)".
bluez-5.76/obexd/plugins/pcsuite.c:379:3: leaked_storage: Freeing "obj" without freeing its pointer field "cmd" leaks the storage that "cmd" points to.
377|
378|	if (send_backup_dbus_message("open", obj, size) == FALSE) {
379|->		g_free(obj);
380|		obj = NULL;
381|	}
---
 obexd/plugins/pcsuite.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c
index 752074c08f45..07c444ff27e0 100644
--- a/obexd/plugins/pcsuite.c
+++ b/obexd/plugins/pcsuite.c
@@ -376,6 +376,7 @@  static void *backup_open(const char *name, int oflag, mode_t mode,
 	obj->error_code = 0;
 
 	if (send_backup_dbus_message("open", obj, size) == FALSE) {
+		g_free(obj->cmd);
 		g_free(obj);
 		obj = NULL;
 	}