Commit 1fe12933 authored by Max Kellermann's avatar Max Kellermann

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.
parent 38fb8a01
...@@ -35,7 +35,7 @@ struct jack_data { ...@@ -35,7 +35,7 @@ struct jack_data {
/* configuration */ /* configuration */
char *name; char *name;
const char *output_ports[2]; char *output_ports[2];
int ringbuffer_size; int ringbuffer_size;
/* for srate() only */ /* for srate() only */
...@@ -299,8 +299,9 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format) ...@@ -299,8 +299,9 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
if (!jd->output_ports[1] && if (!jd->output_ports[1] &&
(jports = jack_get_ports(jd->client, NULL, NULL, (jports = jack_get_ports(jd->client, NULL, NULL,
JackPortIsPhysical | JackPortIsInput))) { JackPortIsPhysical | JackPortIsInput))) {
jd->output_ports[0] = jports[0]; jd->output_ports[0] = g_strdup(jports[0]);
jd->output_ports[1] = jports[1] ? jports[1] : jports[0]; jd->output_ports[1] = g_strdup(jports[1] != NULL
? jports[1] : jports[0]);
g_debug("output_ports: %s %s", g_debug("output_ports: %s %s",
jd->output_ports[0], jd->output_ports[1]); jd->output_ports[0], jd->output_ports[1]);
free(jports); free(jports);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment