From a5f8d4386c3d7b59bab15499d5d70f8d2713626f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 31 Oct 2008 16:47:21 +0100 Subject: update: check return values Nearly all mapper functions can fail and will then return NULL. Add checks to all callers. --- src/song.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/song.c') diff --git a/src/song.c b/src/song.c index d99b3a29f..4ab0afadf 100644 --- a/src/song.c +++ b/src/song.c @@ -94,28 +94,31 @@ song_free(struct song *song) bool song_file_update(struct song *song) { + char buffer[MPD_PATH_MAX]; + const char *path_fs; struct decoder_plugin *plugin; unsigned int next = 0; - char abs_path[MPD_PATH_MAX]; struct stat st; assert(song_is_file(song)); - map_song_fs(song, abs_path); + path_fs = map_song_fs(song, buffer); + if (path_fs == NULL) + return false; if (song->tag != NULL) { tag_free(song->tag); song->tag = NULL; } - if (stat(abs_path, &st) < 0 || !S_ISREG(st.st_mode)) + if (stat(path_fs, &st) < 0 || !S_ISREG(st.st_mode)) return false; song->mtime = st.st_mtime; while (song->tag == NULL && - (plugin = hasMusicSuffix(abs_path, next++))) - song->tag = plugin->tag_dup(abs_path); + (plugin = hasMusicSuffix(path_fs, next++))) + song->tag = plugin->tag_dup(path_fs); return song->tag != NULL; } -- cgit v1.2.3