From e51da0e0fb8c55cb874d87dafc7eec93bee6beb3 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 28 Nov 2009 12:24:44 +0100 Subject: Fix another NULL pointer dereference --- src/main.c | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 08eac48..190a148 100644 --- a/src/main.c +++ b/src/main.c @@ -231,30 +231,35 @@ int main (int argc, char **argv) { BarUiPrintSong (curSong, curStation->isQuickMix ? PianoFindStationById (ph.stations, curSong->stationId) : NULL); - /* setup artist and song name for scrobbling (curSong - * may be NULL later) */ - WardrobeSongInit (&scrobbleSong); - scrobbleSong.artist = strdup (curSong->artist); - scrobbleSong.title = strdup (curSong->title); - scrobbleSong.album = strdup (curSong->album); - scrobbleSong.started = time (NULL); - - /* setup player */ - memset (&player, 0, sizeof (player)); - - WaitressInit (&player.waith); - WaitressSetUrl (&player.waith, curSong->audioUrl); - - player.gain = curSong->fileGain; - player.audioFormat = curSong->audioFormat; - - /* throw event */ - BarUiStartEventCmd (&settings, "songstart", curStation, - curSong, PIANO_RET_OK); - - /* start player */ - pthread_create (&playerThread, NULL, BarPlayerThread, - &player); + + if (curSong->audioUrl == NULL) { + BarUiMsg (MSG_ERR, "Invalid song url\n"); + } else { + /* setup artist and song name for scrobbling (curSong + * may be NULL later) */ + WardrobeSongInit (&scrobbleSong); + scrobbleSong.artist = strdup (curSong->artist); + scrobbleSong.title = strdup (curSong->title); + scrobbleSong.album = strdup (curSong->album); + scrobbleSong.started = time (NULL); + + /* setup player */ + memset (&player, 0, sizeof (player)); + + WaitressInit (&player.waith); + WaitressSetUrl (&player.waith, curSong->audioUrl); + + player.gain = curSong->fileGain; + player.audioFormat = curSong->audioFormat; + + /* throw event */ + BarUiStartEventCmd (&settings, "songstart", curStation, + curSong, PIANO_RET_OK); + + /* start player */ + pthread_create (&playerThread, NULL, BarPlayerThread, + &player); + } } } /* end if curStation != NULL */ } -- cgit v1.2.3