Ensure valid values in watching

This commit is contained in:
Pasi Kallinen 2012-03-17 12:17:02 +02:00
parent 3ef04ef269
commit 7c0741110e
2 changed files with 6 additions and 6 deletions

2
TODO
View File

@ -1,4 +1,6 @@
-xterm title escape codes. Title strings defineable in config file?
-allow setting banners for the internal menus, with the same method -allow setting banners for the internal menus, with the same method
as normal user-defined menus, but only the banner is used from them. as normal user-defined menus, but only the banner is used from them.
if no such menu is defined, then uses the default banner file. if no such menu is defined, then uses the default banner file.

View File

@ -1118,11 +1118,7 @@ inprogressmenu (int gameid)
case ERR: case ERR:
case 'q': case 'Q': case 'q': case 'Q':
case '\x1b': case '\x1b':
free_populated_games(games, len); goto leavewatchgame;
#ifdef USE_SHMEM
shmdt(shm_dg_data);
#endif
return;
case KEY_RIGHT: case KEY_RIGHT:
case '.': case '.':
sortmode_increment(watchcols, &sortmode, 1); sortmode_increment(watchcols, &sortmode, 1);
@ -1162,7 +1158,8 @@ inprogressmenu (int gameid)
break; break;
} else selected = idx; } else selected = idx;
watchgame: watchgame:
if (!(idx >= 0 && idx < len && games[idx] && games[idx]->name))
goto leavewatchgame;
/* valid choice has been made */ /* valid choice has been made */
chosen_name = strdup (games[idx]->name); chosen_name = strdup (games[idx]->name);
snprintf (ttyrecname, 130, "%s", snprintf (ttyrecname, 130, "%s",
@ -1236,6 +1233,7 @@ watchgame:
selectedgame = NULL; selectedgame = NULL;
} }
} }
leavewatchgame:
free_populated_games(games, len); free_populated_games(games, len);
#ifdef USE_SHMEM #ifdef USE_SHMEM
shmdt(shm_dg_data); shmdt(shm_dg_data);