BASE: Check scanf return value when adding a game

This commit is contained in:
Thierry Crozat 2017-04-24 19:53:22 +01:00
parent 0bb8b4051c
commit 5d91efa74d

View File

@ -889,7 +889,10 @@ static bool addGame(Common::String path) {
}
// Get user input
scanf("%i", &idx);
if (scanf("%i", &idx) != 1) {
printf("Invalid index. No game added.\n");
return false;
}
--idx;
if (idx < 0 || idx >= (int)candidates.size()) {
printf("Invalid index. No game added.\n");