diff options
author | Max Kellermann <max@duempel.org> | 2008-10-31 16:47:21 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-31 16:47:21 +0100 |
commit | a5f8d4386c3d7b59bab15499d5d70f8d2713626f (patch) | |
tree | 148790958d648b34564a6c4216f3db42614c7d9d /src/song.c | |
parent | d8e877e3355d0858c78a6d9a7060a6683024dd30 (diff) | |
download | mpd-a5f8d4386c3d7b59bab15499d5d70f8d2713626f.tar.gz mpd-a5f8d4386c3d7b59bab15499d5d70f8d2713626f.tar.xz mpd-a5f8d4386c3d7b59bab15499d5d70f8d2713626f.zip |
update: check return values
Nearly all mapper functions can fail and will then return NULL. Add
checks to all callers.
Diffstat (limited to '')
-rw-r--r-- | src/song.c | 13 |
1 files changed, 8 insertions, 5 deletions
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; } |