diff mbox series

[BlueZ,V2] media: Fix scan-build warnings

Message ID 20220831000548.1222374-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,V2] media: Fix scan-build warnings | expand

Commit Message

Luiz Augusto von Dentz Aug. 31, 2022, 12:05 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This fixes the following warnings:

profiles/audio/media.c:1465:6: warning: 8th function call argument
is an uninitialized value
        if (media_endpoint_create(adapter, sender, path, uuid, delay_reporting,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3012:3: warning: Use of memory after it is freed
                release_endpoint(adapter->endpoints->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3015:3: warning: Use of memory after it is freed
                media_player_destroy(adapter->players->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 profiles/audio/media.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index a7fa85d60310..49d8fc2f5e53 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -1440,7 +1440,7 @@  static DBusMessage *register_endpoint(DBusConnection *conn, DBusMessage *msg,
 	gboolean delay_reporting = FALSE;
 	uint8_t codec = 0;
 	struct bt_bap_pac_qos qos = {};
-	uint8_t *capabilities;
+	uint8_t *capabilities = NULL;
 	int size = 0;
 	int err;
 
@@ -3005,14 +3005,15 @@  static const GDBusPropertyTable media_properties[] = {
 static void path_free(void *data)
 {
 	struct media_adapter *adapter = data;
+	GSList *l;
 
 	queue_destroy(adapter->apps, app_free);
 
-	while (adapter->endpoints)
-		release_endpoint(adapter->endpoints->data);
+	for (l = adapter->endpoints; l; l = g_slist_next(l))
+		release_endpoint(l->data);
 
-	while (adapter->players)
-		media_player_destroy(adapter->players->data);
+	for (l = adapter->players; l; l = g_slist_next(l))
+		media_player_destroy(l->data);
 
 	adapters = g_slist_remove(adapters, adapter);