Commit 7820ebb8 authored by Max Kellermann's avatar Max Kellermann

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.
parent 31ab0b3d
...@@ -172,11 +172,18 @@ directory_load(FILE *fp, struct directory *directory, ...@@ -172,11 +172,18 @@ directory_load(FILE *fp, struct directory *directory,
songvec_add(&directory->songs, song); songvec_add(&directory->songs, song);
} else if (g_str_has_prefix(line, PLAYLIST_META_BEGIN)) { } 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, if (!playlist_metadata_load(fp, &directory->playlists,
name, buffer, error)) name, buffer, error)) {
g_free(name);
return false; return false;
}
g_free(name);
} else { } else {
g_set_error(error, directory_quark(), 0, g_set_error(error, directory_quark(), 0,
"Malformed line: %s", line); "Malformed line: %s", line);
......
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