aboutsummaryrefslogtreecommitdiffstats
path: root/src/mapper.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-02 10:48:55 +0100
committerMax Kellermann <max@duempel.org>2009-01-02 10:48:55 +0100
commitdaf7c3db5aac09a8376f1c8ed499eb17202f77a9 (patch)
treeca912c4ff8c7985431a7e99cb3ea5a9393e09c2a /src/mapper.c
parent72255d580e23405375562160bf05fb55d3248f39 (diff)
downloadmpd-daf7c3db5aac09a8376f1c8ed499eb17202f77a9.tar.gz
mpd-daf7c3db5aac09a8376f1c8ed499eb17202f77a9.tar.xz
mpd-daf7c3db5aac09a8376f1c8ed499eb17202f77a9.zip
mapper: allocate the result of map_directory_child_fs(), map_song_fs()
Don't use fixed stack buffers.
Diffstat (limited to 'src/mapper.c')
-rw-r--r--src/mapper.c23
1 files changed, 12 insertions, 11 deletions
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 *