alsa: Fix crash when loading bare ALSA sink/source

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.
This commit is contained in:
Jan Alexander Steffens (heftig) 2013-10-09 20:29:39 +02:00 committed by Arun Raghavan
parent 35fea579cb
commit f81e3e1d78
2 changed files with 20 additions and 16 deletions

View file

@ -2032,6 +2032,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
map = m->core->default_channel_map; map = m->core->default_channel_map;
/* Pick sample spec overrides from the mapping, if any */ /* Pick sample spec overrides from the mapping, if any */
if (mapping) {
if (mapping->sample_spec.format != PA_SAMPLE_INVALID) if (mapping->sample_spec.format != PA_SAMPLE_INVALID)
ss.format = mapping->sample_spec.format; ss.format = mapping->sample_spec.format;
if (mapping->sample_spec.rate != 0) if (mapping->sample_spec.rate != 0)
@ -2041,6 +2042,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
if (pa_channel_map_valid(&mapping->channel_map)) if (pa_channel_map_valid(&mapping->channel_map))
pa_assert(pa_channel_map_compatible(&mapping->channel_map, &ss)); pa_assert(pa_channel_map_compatible(&mapping->channel_map, &ss));
} }
}
/* Override with modargs if provided */ /* Override with modargs if provided */
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_ALSA) < 0) { if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_ALSA) < 0) {

View file

@ -1742,6 +1742,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
map = m->core->default_channel_map; map = m->core->default_channel_map;
/* Pick sample spec overrides from the mapping, if any */ /* Pick sample spec overrides from the mapping, if any */
if (mapping) {
if (mapping->sample_spec.format != PA_SAMPLE_INVALID) if (mapping->sample_spec.format != PA_SAMPLE_INVALID)
ss.format = mapping->sample_spec.format; ss.format = mapping->sample_spec.format;
if (mapping->sample_spec.rate != 0) if (mapping->sample_spec.rate != 0)
@ -1751,6 +1752,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
if (pa_channel_map_valid(&mapping->channel_map)) if (pa_channel_map_valid(&mapping->channel_map))
pa_assert(pa_channel_map_compatible(&mapping->channel_map, &ss)); pa_assert(pa_channel_map_compatible(&mapping->channel_map, &ss));
} }
}
/* Override with modargs if provided */ /* Override with modargs if provided */
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_ALSA) < 0) { if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_ALSA) < 0) {