aboutsummaryrefslogtreecommitdiff
path: root/base/commandLine.cpp
diff options
context:
space:
mode:
authorThierry Crozat2017-04-24 19:53:22 +0100
committerThierry Crozat2017-04-24 20:04:05 +0100
commit5d91efa74d2f3228c88c9af01541e0e2d7912d47 (patch)
treec239badbcdf98b3ee2ae90282739841f71504631 /base/commandLine.cpp
parent0bb8b4051c50ccf2178f4778fad2485732899754 (diff)
downloadscummvm-rg350-5d91efa74d2f3228c88c9af01541e0e2d7912d47.tar.gz
scummvm-rg350-5d91efa74d2f3228c88c9af01541e0e2d7912d47.tar.bz2
scummvm-rg350-5d91efa74d2f3228c88c9af01541e0e2d7912d47.zip
BASE: Check scanf return value when adding a game
Diffstat (limited to 'base/commandLine.cpp')
-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");