aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/commandLine.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index e77ab6ce86..4f3d5687b4 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -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");