summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-12-18 12:37:27 +0100
committerLars-Dominik Braun <lars@6xq.net>2011-12-18 12:37:27 +0100
commitd20878bce0c0d84e5b49d1b9642e71bb0d18341a (patch)
tree33424c7055ed6de36514e7ac37dd8c5f5d33b2c2 /src
parent39a2ff7d44ccb19ea4de98fc52234d2506898275 (diff)
downloadpianobar-windows-d20878bce0c0d84e5b49d1b9642e71bb0d18341a.tar.gz
pianobar-windows-d20878bce0c0d84e5b49d1b9642e71bb0d18341a.tar.bz2
pianobar-windows-d20878bce0c0d84e5b49d1b9642e71bb0d18341a.zip
Fix genre selection segfault
Closes #193 and #194
Diffstat (limited to 'src')
-rw-r--r--src/ui.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/ui.c b/src/ui.c
index 7c80079..9a76266 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -584,16 +584,19 @@ void BarStationFromGenre (BarApp_t *app) {
i++;
curCat = curCat->next;
}
- /* select category or exit */
- BarUiMsg (&app->settings, MSG_QUESTION, "Select category: ");
- if (BarReadlineInt (&i, &app->input) == 0) {
- return;
- }
- curCat = app->ph.genreStations;
- while (curCat != NULL && i > 0) {
- curCat = curCat->next;
- i--;
- }
+
+ do {
+ /* select category or exit */
+ BarUiMsg (&app->settings, MSG_QUESTION, "Select category: ");
+ if (BarReadlineInt (&i, &app->input) == 0) {
+ return;
+ }
+ curCat = app->ph.genreStations;
+ while (curCat != NULL && i > 0) {
+ curCat = curCat->next;
+ i--;
+ }
+ } while (curCat == NULL);
/* print all available stations */
curGenre = curCat->genres;
@@ -603,15 +606,19 @@ void BarStationFromGenre (BarApp_t *app) {
i++;
curGenre = curGenre->next;
}
- BarUiMsg (&app->settings, MSG_QUESTION, "Select genre: ");
- if (BarReadlineInt (&i, &app->input) == 0) {
- return;
- }
- curGenre = curCat->genres;
- while (curGenre != NULL && i > 0) {
- curGenre = curGenre->next;
- i--;
- }
+
+ do {
+ BarUiMsg (&app->settings, MSG_QUESTION, "Select genre: ");
+ if (BarReadlineInt (&i, &app->input) == 0) {
+ return;
+ }
+ curGenre = curCat->genres;
+ while (curGenre != NULL && i > 0) {
+ curGenre = curGenre->next;
+ i--;
+ }
+ } while (curGenre == NULL);
+
/* create station */
BarUiMsg (&app->settings, MSG_INFO, "Adding shared station \"%s\"... ", curGenre->name);
reqData.id = curGenre->musicId;