jack: duplicate jack_get_ports() return values

JACK documentation states: "The caller is responsible for calling
free(3) any non-NULL returned value."

This does not seem to include the array elements.  Duplicate them
after jack_get_ports(), and free only the array.  Convert
JackData.output_ports to non-const.
This commit is contained in:
Max Kellermann 2009-01-02 17:23:00 +01:00
parent 38fb8a01c1
commit 1fe129330e

View File

@ -35,7 +35,7 @@ struct jack_data {
/* configuration */
char *name;
const char *output_ports[2];
char *output_ports[2];
int ringbuffer_size;
/* for srate() only */
@ -299,8 +299,9 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
if (!jd->output_ports[1] &&
(jports = jack_get_ports(jd->client, NULL, NULL,
JackPortIsPhysical | JackPortIsInput))) {
jd->output_ports[0] = jports[0];
jd->output_ports[1] = jports[1] ? jports[1] : jports[0];
jd->output_ports[0] = g_strdup(jports[0]);
jd->output_ports[1] = g_strdup(jports[1] != NULL
? jports[1] : jports[0]);
g_debug("output_ports: %s %s",
jd->output_ports[0], jd->output_ports[1]);
free(jports);