module-jack-sink/source: protect against null return in jack_get_ports

Just picking up a crash report from Ubuntu, here's the result.

--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic

From 934c52c79bb6faed56a64d6e15f9b285f687afee Mon Sep 17 00:00:00 2001
From: David Henningsson <david.henningsson@canonical.com>
Date: Mon, 28 Mar 2011 14:30:44 +0200
Subject: [PATCH] module-jack-sink/source: protect against null return in jack_get_ports

According to jack_get_ports documentation, it seems like returning NULL
is valid, and that it should be freed using jack_free.

Reported-by: Grayson Peddie
BugLink: http://bugs.launchpad.net/bugs/733424
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
David Henningsson 2011-03-28 15:16:12 +02:00 committed by Colin Guthrie
parent 4be49ae94b
commit fd5b282f51
2 changed files with 16 additions and 10 deletions

View file

@ -343,8 +343,9 @@ int pa__init(pa_module*m) {
ports = jack_get_ports(u->client, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsInput);
channels = 0;
for (p = ports; *p; p++)
channels++;
if (ports)
for (p = ports; *p; p++)
channels++;
if (!channels)
channels = m->core->default_sample_spec.channels;
@ -432,7 +433,7 @@ int pa__init(pa_module*m) {
if (do_connect) {
for (i = 0, p = ports; i < ss.channels; i++, p++) {
if (!*p) {
if (!p || !*p) {
pa_log("Not enough physical output ports, leaving unconnected.");
break;
}
@ -448,7 +449,8 @@ int pa__init(pa_module*m) {
pa_sink_put(u->sink);
free(ports);
if (ports)
jack_free(ports);
pa_modargs_free(ma);
return 0;
@ -457,7 +459,8 @@ fail:
if (ma)
pa_modargs_free(ma);
free(ports);
if (ports)
jack_free(ports);
pa__done(m);

View file

@ -289,8 +289,9 @@ int pa__init(pa_module*m) {
ports = jack_get_ports(u->client, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsOutput);
channels = 0;
for (p = ports; *p; p++)
channels++;
if (ports)
for (p = ports; *p; p++)
channels++;
if (!channels)
channels = m->core->default_sample_spec.channels;
@ -376,7 +377,7 @@ int pa__init(pa_module*m) {
if (do_connect) {
for (i = 0, p = ports; i < ss.channels; i++, p++) {
if (!*p) {
if (!p || !*p) {
pa_log("Not enough physical output ports, leaving unconnected.");
break;
}
@ -393,7 +394,8 @@ int pa__init(pa_module*m) {
pa_source_put(u->source);
free(ports);
if (ports)
jack_free(ports);
pa_modargs_free(ma);
return 0;
@ -402,7 +404,8 @@ fail:
if (ma)
pa_modargs_free(ma);
free(ports);
if (ports)
jack_free(ports);
pa__done(m);