diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-11-28 12:24:44 +0100 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-11-28 12:24:44 +0100 |
commit | e51da0e0fb8c55cb874d87dafc7eec93bee6beb3 (patch) | |
tree | 17b3ee3448900c0238c3946cf8c1108a79c4b23c | |
parent | 7dff801f34a76dd7950fc1751ce5ee2978e9b32d (diff) | |
download | pianobar-e51da0e0fb8c55cb874d87dafc7eec93bee6beb3.tar.gz pianobar-e51da0e0fb8c55cb874d87dafc7eec93bee6beb3.tar.bz2 pianobar-e51da0e0fb8c55cb874d87dafc7eec93bee6beb3.zip |
Fix another NULL pointer dereference
-rw-r--r-- | src/main.c | 53 |
1 files changed, 29 insertions, 24 deletions
@@ -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 */ } |