summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-28 13:28:18 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-28 13:28:18 +0200
commite052ad9950867f53ca769ad90f9f52f0341cf4dd (patch)
tree03e790f5092919c8006d316402ae2e00eb64245b /src
parent3b6b49c735331e58767f2635859d557058cbde18 (diff)
downloadpianobar-e052ad9950867f53ca769ad90f9f52f0341cf4dd.tar.gz
pianobar-e052ad9950867f53ca769ad90f9f52f0341cf4dd.tar.bz2
pianobar-e052ad9950867f53ca769ad90f9f52f0341cf4dd.zip
client: Fix some UI NULL pointer dereferences (no song/station selected)
Diffstat (limited to 'src')
-rw-r--r--src/main.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 51b4f3e..aa338eb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -365,7 +365,7 @@ int main (int argc, char **argv) {
read (fileno (stdin), &buf, sizeof (buf));
switch (buf) {
case '?':
- printf ("a\tadd music to current station\n"
+ printf ("\na\tadd music to current station\n"
"b\tban current song\n"
"c\tcreate new station\n"
"d\tdelete current station\n"
@@ -379,6 +379,10 @@ int main (int argc, char **argv) {
break;
case 'a':
+ if (curStation == NULL) {
+ BarUiMsg ("No station selected.\n");
+ break;
+ }
musicId = BarUiSelectMusicId (&ph);
if (musicId == NULL) {
BarUiMsg ("Aborted.\n");
@@ -395,11 +399,15 @@ int main (int argc, char **argv) {
break;
case 'b':
- player.doQuit = 1;
+ if (curStation == NULL || curSong == NULL) {
+ BarUiMsg ("No song playing.\n");
+ break;
+ }
BarUiMsg ("Banning song... ");
if (PianoRateTrack (&ph, curStation, curSong,
PIANO_RATE_BAN) == PIANO_RET_OK) {
BarUiMsg ("Ok.\n");
+ player.doQuit = 1;
} else {
BarUiMsg ("Error.\n");
}
@@ -424,6 +432,10 @@ int main (int argc, char **argv) {
break;
case 'd':
+ if (curStation == NULL) {
+ BarUiMsg ("No station selected.\n");
+ break;
+ }
printf ("Really delete \"%s\"? [yn]\n",
curStation->name);
read (fileno (stdin), &yesnoBuf, sizeof (yesnoBuf));
@@ -443,6 +455,10 @@ int main (int argc, char **argv) {
break;
case 'l':
+ if (curStation == NULL || curSong == NULL) {
+ BarUiMsg ("No song playing.\n");
+ break;
+ }
if (curSong->rating == PIANO_RATE_LOVE) {
BarUiMsg ("Already loved. No need to do this twice.\n");
break;
@@ -461,9 +477,13 @@ int main (int argc, char **argv) {
break;
case 'm':
+ if (curStation == NULL || curSong == NULL) {
+ BarUiMsg ("No song playing.\n");
+ break;
+ }
moveStation = BarUiSelectStation (&ph);
if (moveStation != NULL) {
- printf ("Moving song to \"%s\"...", moveStation->name);
+ printf ("Moving song to \"%s\"... ", moveStation->name);
fflush (stdout);
if (PianoMoveSong (&ph, curStation, moveStation,
curSong) == PIANO_RET_OK) {
@@ -485,6 +505,10 @@ int main (int argc, char **argv) {
break;
case 'r':
+ if (curStation == NULL) {
+ BarUiMsg ("No station selected.\n");
+ break;
+ }
lineBuf = readline ("New name?\n");
if (lineBuf != NULL && strlen (lineBuf) > 0) {
BarUiMsg ("Renaming station... ");
@@ -511,6 +535,10 @@ int main (int argc, char **argv) {
break;
case 't':
+ if (curStation == NULL || curSong == NULL) {
+ BarUiMsg ("No song playing.\n");
+ break;
+ }
BarUiMsg ("Putting song on shelf... ");
if (PianoSongTired (&ph, curSong) == PIANO_RET_OK) {
BarUiMsg ("Ok.\n");