pbap: Fix memory leak
authorGopal Tiwari <gtiwari@redhat.com>
Tue, 31 May 2022 07:41:15 +0000 (13:11 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
Reported by coverity tool as follows:

bluez-5.64/obexd/client/pbap.c:929: leaked_storage: Variable "apparam"
going out of scope leaks the storage it points to.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
obexd/client/pbap.c

index 3332790..5404f66 100755 (executable)
@@ -972,10 +972,11 @@ static DBusMessage *pbap_search(DBusConnection *connection,
                return g_dbus_create_error(message,
                                ERROR_INTERFACE ".InvalidArguments", NULL);
 
-       if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+       if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING) {
+               g_obex_apparam_free(apparam);
                return g_dbus_create_error(message,
                                ERROR_INTERFACE ".InvalidArguments", NULL);
-
+       }
        dbus_message_iter_get_basic(&args, &value);
        dbus_message_iter_next(&args);