aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-07-25 12:01:29 +0200
committerMax Kellermann <max@duempel.org>2010-07-25 12:01:59 +0200
commit7820ebb82ea66619ae72caf3bdeb7fd16d035fdd (patch)
treee4779f8df85ac2168bf16a78ed0a816527e31c02
parent31ab0b3df116652c1e42204d1f074670ffdc1623 (diff)
downloadmpd-7820ebb82ea66619ae72caf3bdeb7fd16d035fdd.tar.gz
mpd-7820ebb82ea66619ae72caf3bdeb7fd16d035fdd.tar.xz
mpd-7820ebb82ea66619ae72caf3bdeb7fd16d035fdd.zip
directory_save: duplicate the playlist name
The function playlist_metadata_load() will overwrite the input buffer before using the "name" parameter; since "name" points to the same buffer, we'll get a corrupted string.
-rw-r--r--src/directory_save.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/directory_save.c b/src/directory_save.c
index af134d9a2..55896c289 100644
--- a/src/directory_save.c
+++ b/src/directory_save.c
@@ -172,11 +172,18 @@ directory_load(FILE *fp, struct directory *directory,
songvec_add(&directory->songs, song);
} else if (g_str_has_prefix(line, PLAYLIST_META_BEGIN)) {
- const char *name = line + sizeof(PLAYLIST_META_BEGIN) - 1;
+ /* duplicate the name, because
+ playlist_metadata_load() will overwrite the
+ buffer */
+ char *name = g_strdup(line + sizeof(PLAYLIST_META_BEGIN) - 1);
if (!playlist_metadata_load(fp, &directory->playlists,
- name, buffer, error))
+ name, buffer, error)) {
+ g_free(name);
return false;
+ }
+
+ g_free(name);
} else {
g_set_error(error, directory_quark(), 0,
"Malformed line: %s", line);