diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-05 20:13:50 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-05 20:13:50 -0700 |
commit | c344fa6a506d117f1e4c9a6213c5c94937631ff9 (patch) | |
tree | 682afaf535c247c6992645694e8749a1a7aa8f60 /src | |
parent | 8a2306146149d4d7915ed1346a7dbd908fb1048f (diff) | |
download | mpd-c344fa6a506d117f1e4c9a6213c5c94937631ff9.tar.gz mpd-c344fa6a506d117f1e4c9a6213c5c94937631ff9.tar.xz mpd-c344fa6a506d117f1e4c9a6213c5c94937631ff9.zip |
Assert if we don't have song or song->url set
song objects cannot exist without a path or URL
Diffstat (limited to 'src')
-rw-r--r-- | src/directory.c | 4 | ||||
-rw-r--r-- | src/song.c | 10 |
2 files changed, 10 insertions, 4 deletions
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); |