summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-12 17:14:56 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-12 17:14:56 +0200
commit35c306d0e917a3fcbca30e9ad09a214e57548edd (patch)
tree97a2d49be03ccb3073c2aa1514c130c93e3944b8 /src
parentc5819e14350678efc1e2415191848e87f0f21f85 (diff)
downloadpianobar-35c306d0e917a3fcbca30e9ad09a214e57548edd.tar.gz
pianobar-35c306d0e917a3fcbca30e9ad09a214e57548edd.tar.bz2
pianobar-35c306d0e917a3fcbca30e9ad09a214e57548edd.zip
client: Fix segfaults when changing station, banning and skipping tracks
This was caused by reading uninitialized memory. It was freed by PianoDestroyPlaylist.
Diffstat (limited to 'src')
-rw-r--r--src/main.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index a032be3..0dcac22 100644
--- a/src/main.c
+++ b/src/main.c
@@ -261,7 +261,6 @@ int main (int argc, char **argv) {
curSong = ph.playlist;
/* play first track */
while (!doQuit) {
- PianoSong_t *lastSong = NULL;
pthread_t playerThread;
printf ("\"%s\" by \"%s\"%s\n", curSong->title, curSong->artist,
(curSong->rating == PIANO_RATE_LOVE) ? " (Loved)" : "");
@@ -294,6 +293,7 @@ int main (int argc, char **argv) {
}
/* pandora does this too, I think */
PianoDestroyPlaylist (&ph);
+ curSong = NULL;
break;
case 'd':
@@ -306,6 +306,7 @@ int main (int argc, char **argv) {
player.doQuit = 1;
printf ("Deleted.\n");
PianoDestroyPlaylist (&ph);
+ curSong = NULL;
curStation = selectStation (&ph);
} else {
printf ("Error while deleting station.\n");
@@ -353,6 +354,7 @@ int main (int argc, char **argv) {
case 's':
player.doQuit = 1;
PianoDestroyPlaylist (&ph);
+ curSong = NULL;
curStation = selectStation (&ph);
printf ("changed station to %s\n", curStation->name);
break;
@@ -363,8 +365,9 @@ int main (int argc, char **argv) {
free (player.url);
/* what's next? */
- lastSong = curSong;
- curSong = lastSong->next;
+ if (curSong != NULL) {
+ curSong = curSong->next;
+ }
if (curSong == NULL && !doQuit) {
printf ("receiving new playlist\n");
PianoDestroyPlaylist (&ph);