OSDN Git Service

Fix GLib assertion failure in media.c get_setting()
authorSzymon Janc <szymon.janc@tieto.com>
Thu, 2 Feb 2012 22:21:19 +0000 (23:21 +0100)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 2 Feb 2012 23:56:42 +0000 (15:56 -0800)
If get_setting is called before set_setting, mp->settings would be
NULL resulting in GLib assertion. Hashmap is now allocated in
media_player_create instead of on-demand allocation in set_setting.

external/bluetooth/bluez/audio/media.c:get_setting() Equalizer
CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed

audio/media.c

index a363b8e..c0fd0c3 100644 (file)
@@ -1371,9 +1371,6 @@ static gboolean set_property(struct media_player *mp, const char *key,
 
        DBG("%s=%s", key, value);
 
-       if (!mp->settings)
-               mp->settings = g_hash_table_new(g_direct_hash, g_direct_equal);
-
        g_hash_table_replace(mp->settings, GUINT_TO_POINTER(attr),
                                                GUINT_TO_POINTER(val));
 
@@ -1595,6 +1592,8 @@ static struct media_player *media_player_create(struct media_adapter *adapter,
                return NULL;
        }
 
+       mp->settings = g_hash_table_new(g_direct_hash, g_direct_equal);
+
        adapter->players = g_slist_append(adapter->players, mp);
 
        info("Player registered: sender=%s path=%s", sender, path);