]> code.delx.au - pulseaudio/commitdiff
alsa: Fix crash when loading bare ALSA sink/source
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Wed, 9 Oct 2013 18:29:39 +0000 (20:29 +0200)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Wed, 9 Oct 2013 18:33:56 +0000 (00:03 +0530)
module-alsa-{sink,source}.c call pa_alsa_{sink,source}_new with
mapping set to NULL. Guard against this, like the rest of the
function does.

module-alsa-card does not use NULL, so this went unnoticed so far.

src/modules/alsa/alsa-sink.c
src/modules/alsa/alsa-source.c

index d3d5b19a39c2c5e8ad2011eee3d0470f9a05f203..e10e14e12ae6ae820db8b1ca9b78b736f9617d14 100644 (file)
@@ -2032,14 +2032,16 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     map = m->core->default_channel_map;
 
     /* Pick sample spec overrides from the mapping, if any */
-    if (mapping->sample_spec.format != PA_SAMPLE_INVALID)
-        ss.format = mapping->sample_spec.format;
-    if (mapping->sample_spec.rate != 0)
-        ss.rate = mapping->sample_spec.rate;
-    if (mapping->sample_spec.channels != 0) {
-        ss.channels = mapping->sample_spec.channels;
-        if (pa_channel_map_valid(&mapping->channel_map))
-            pa_assert(pa_channel_map_compatible(&mapping->channel_map, &ss));
+    if (mapping) {
+        if (mapping->sample_spec.format != PA_SAMPLE_INVALID)
+            ss.format = mapping->sample_spec.format;
+        if (mapping->sample_spec.rate != 0)
+            ss.rate = mapping->sample_spec.rate;
+        if (mapping->sample_spec.channels != 0) {
+            ss.channels = mapping->sample_spec.channels;
+            if (pa_channel_map_valid(&mapping->channel_map))
+                pa_assert(pa_channel_map_compatible(&mapping->channel_map, &ss));
+        }
     }
 
     /* Override with modargs if provided */
index 8416ba8ae5b50b1c95992f5751b10d6edadf843b..2e93e0fecc9ccfc76bb8b60522b9b379ec2c36d5 100644 (file)
@@ -1742,14 +1742,16 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
     map = m->core->default_channel_map;
 
     /* Pick sample spec overrides from the mapping, if any */
-    if (mapping->sample_spec.format != PA_SAMPLE_INVALID)
-        ss.format = mapping->sample_spec.format;
-    if (mapping->sample_spec.rate != 0)
-        ss.rate = mapping->sample_spec.rate;
-    if (mapping->sample_spec.channels != 0) {
-        ss.channels = mapping->sample_spec.channels;
-        if (pa_channel_map_valid(&mapping->channel_map))
-            pa_assert(pa_channel_map_compatible(&mapping->channel_map, &ss));
+    if (mapping) {
+        if (mapping->sample_spec.format != PA_SAMPLE_INVALID)
+            ss.format = mapping->sample_spec.format;
+        if (mapping->sample_spec.rate != 0)
+            ss.rate = mapping->sample_spec.rate;
+        if (mapping->sample_spec.channels != 0) {
+            ss.channels = mapping->sample_spec.channels;
+            if (pa_channel_map_valid(&mapping->channel_map))
+                pa_assert(pa_channel_map_compatible(&mapping->channel_map, &ss));
+        }
     }
 
     /* Override with modargs if provided */