From daf7c3db5aac09a8376f1c8ed499eb17202f77a9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 2 Jan 2009 10:48:55 +0100 Subject: mapper: allocate the result of map_directory_child_fs(), map_song_fs() Don't use fixed stack buffers. --- src/mapper.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/mapper.c') diff --git a/src/mapper.c b/src/mapper.c index 6b0a7a449..bd19af615 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -108,11 +108,11 @@ map_directory_fs(const struct directory *directory) return map_uri_fs(dirname); } -const char * -map_directory_child_fs(const struct directory *directory, const char *name, - char *buffer) +char * +map_directory_child_fs(const struct directory *directory, const char *name) { - char *parent_fs; + char buffer[MPD_PATH_MAX]; + char *parent_fs, *path; /* check for invalid or unauthorized base names */ if (*name == 0 || strchr(name, '/') != NULL || @@ -124,21 +124,22 @@ map_directory_child_fs(const struct directory *directory, const char *name, return NULL; name = utf8_to_fs_charset(buffer, name); - pfx_dir(buffer, name, strlen(name), - parent_fs, strlen(parent_fs)); + path = g_build_filename(parent_fs, name, NULL); g_free(parent_fs); - return buffer; + return path; } -const char * -map_song_fs(const struct song *song, char *buffer) +char * +map_song_fs(const struct song *song) { + char buffer[MPD_PATH_MAX]; + assert(song_is_file(song)); if (song_in_database(song)) - return map_directory_child_fs(song->parent, song->url, buffer); + return map_directory_child_fs(song->parent, song->url); else - return utf8_to_fs_charset(buffer, song->url); + return g_strdup(utf8_to_fs_charset(buffer, song->url)); } const char * -- cgit v1.2.3