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/song.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/song.c') diff --git a/src/song.c b/src/song.c index b7a8d2f8a..4d93073a9 100644 --- a/src/song.c +++ b/src/song.c @@ -104,15 +104,14 @@ song_free(struct song *song) bool song_file_update(struct song *song) { - char buffer[MPD_PATH_MAX]; - const char *path_fs; + char *path_fs; const struct decoder_plugin *plugin; unsigned int next = 0; struct stat st; assert(song_is_file(song)); - path_fs = map_song_fs(song, buffer); + path_fs = map_song_fs(song); if (path_fs == NULL) return false; @@ -121,8 +120,10 @@ song_file_update(struct song *song) song->tag = NULL; } - if (stat(path_fs, &st) < 0 || !S_ISREG(st.st_mode)) + if (stat(path_fs, &st) < 0 || !S_ISREG(st.st_mode)) { + g_free(path_fs); return false; + } song->mtime = st.st_mtime; @@ -130,19 +131,19 @@ song_file_update(struct song *song) (plugin = hasMusicSuffix(path_fs, next++))) song->tag = plugin->tag_dup(path_fs); + g_free(path_fs); return song->tag != NULL; } bool song_file_update_inarchive(struct song *song) { - char buffer[MPD_PATH_MAX]; - const char *path_fs; + char *path_fs; const struct decoder_plugin *plugin; assert(song_is_file(song)); - path_fs = map_song_fs(song, buffer); + path_fs = map_song_fs(song); if (path_fs == NULL) return false; @@ -154,6 +155,7 @@ song_file_update_inarchive(struct song *song) //because we dont support tag reading throught //input streams plugin = hasMusicSuffix(path_fs, 0); + g_free(path_fs); if (plugin) { song->tag = tag_new(); //tag_add_item(tag, TAG_ITEM_TITLE, f->title); -- cgit v1.2.3