From c344fa6a506d117f1e4c9a6213c5c94937631ff9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 5 Oct 2008 20:13:50 -0700 Subject: Assert if we don't have song or song->url set song objects cannot exist without a path or URL --- src/directory.c | 4 ++-- src/song.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/directory.c b/src/directory.c index 5dbab5018..57a615cbd 100644 --- a/src/directory.c +++ b/src/directory.c @@ -296,8 +296,8 @@ removeDeletedFromDirectory(char *path_max_tmp, Directory * directory) for (i = sv->nr; --i >= 0; ) { /* cleaner deletes if we go backwards */ Song *song = sv->base[i]; - if (!song || !*song->url) - continue; /* does this happen?, perhaps assert() */ + assert(song); + assert(*song->url); if (dirname) sprintf(path_max_tmp, "%s/%s", dirname, song->url); diff --git a/src/song.c b/src/song.c index ab98963ad..27f48ad03 100644 --- a/src/song.c +++ b/src/song.c @@ -31,8 +31,13 @@ static Song * song_alloc(const char *url, Directory *parent) { - size_t urllen = strlen(url); - Song *song = xmalloc(sizeof(Song) + urllen); + size_t urllen; + Song *song; + + assert(url); + urllen = strlen(url); + assert(urllen); + song = xmalloc(sizeof(Song) + urllen); song->tag = NULL; memcpy(song->url, url, urllen + 1); @@ -44,6 +49,7 @@ static Song * song_alloc(const char *url, Directory *parent) Song *newSong(const char *url, Directory * parentDir) { Song *song; + assert(*url); if (strchr(url, '\n')) { DEBUG("newSong: '%s' is not a valid uri\n", url); -- cgit v1.2.3