diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-07 21:20:34 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-07 21:20:34 +0200 |
commit | 0d34815f6cfe1a75467e7c8f9406ff15bcbe10ba (patch) | |
tree | d205636c8092c76ac235c90e51dff19ff3742547 /src/song.c | |
parent | 016af692d9b7040ec1cd15c92a70ecb4000003f6 (diff) | |
download | mpd-0d34815f6cfe1a75467e7c8f9406ff15bcbe10ba.tar.gz mpd-0d34815f6cfe1a75467e7c8f9406ff15bcbe10ba.tar.xz mpd-0d34815f6cfe1a75467e7c8f9406ff15bcbe10ba.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/song.c')
-rw-r--r-- | src/song.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/song.c b/src/song.c index 54e9ea7e0..acc19eb0e 100644 --- a/src/song.c +++ b/src/song.c @@ -31,8 +31,13 @@ Song * song_alloc(const char *url, struct _Directory *parent) { - size_t urllen = strlen(url); - Song *song = xmalloc(sizeof(*song) - sizeof(song->url) + urllen + 1); + size_t urllen; + Song *song; + + assert(url); + urllen = strlen(url); + assert(urllen); + song = xmalloc(sizeof(*song) - sizeof(song->url) + urllen + 1); song->tag = NULL; memcpy(song->url, url, urllen + 1); @@ -44,6 +49,7 @@ song_alloc(const char *url, struct _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); |