]> code.delx.au - pulseaudio/commitdiff
alsa-mixer: Don't use dangling pointers as port hashmap keys
authorDavid Henningsson <david.henningsson@canonical.com>
Wed, 15 Feb 2012 15:51:31 +0000 (16:51 +0100)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Sun, 19 Feb 2012 17:15:41 +0000 (22:45 +0530)
If alsa settings/options were used, the string to construct the
name was freed, leading to dangling pointers to strings inside
the hashmap.

BugLink: https://bugs.launchpad.net/bugs/932804
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
src/modules/alsa/alsa-mixer.c

index 9bf80695735d468af1b7e42a4680b3459127fd2d..7e6ef5420604b8ec1a20a33fbdf03554c3bdefa8 100644 (file)
@@ -4397,7 +4397,7 @@ static pa_device_port* device_port_alsa_init(pa_hashmap *ports,
 
         p = pa_device_port_new(core, name, description, sizeof(pa_alsa_port_data));
         pa_assert(p);
-        pa_hashmap_put(ports, name, p);
+        pa_hashmap_put(ports, p->name, p);
         p->profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
 
         data = PA_DEVICE_PORT_DATA(p);
@@ -4412,7 +4412,7 @@ static pa_device_port* device_port_alsa_init(pa_hashmap *ports,
         pa_hashmap_put(p->profiles, cp->name, cp);
 
     if (extra) {
-        pa_hashmap_put(extra, name, p);
+        pa_hashmap_put(extra, p->name, p);
         pa_device_port_ref(p);
     }