aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/jack_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-02 17:23:00 +0100
committerMax Kellermann <max@duempel.org>2009-01-02 17:23:00 +0100
commit1fe129330eb76d6b38884041b7b9a13de427e7a5 (patch)
tree49b354c0ef4088e4057849caf89b3424ad232108 /src/output/jack_plugin.c
parent38fb8a01c1721ab9aefe8a38e8e8d220cf6cf447 (diff)
downloadmpd-1fe129330eb76d6b38884041b7b9a13de427e7a5.tar.gz
mpd-1fe129330eb76d6b38884041b7b9a13de427e7a5.tar.xz
mpd-1fe129330eb76d6b38884041b7b9a13de427e7a5.zip
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.
Diffstat (limited to 'src/output/jack_plugin.c')
-rw-r--r--src/output/jack_plugin.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/output/jack_plugin.c b/src/output/jack_plugin.c
index d3a718cd1..14bf81b2c 100644
--- a/src/output/jack_plugin.c
+++ b/src/output/jack_plugin.c
@@ -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);