From 5d91efa74d2f3228c88c9af01541e0e2d7912d47 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Mon, 24 Apr 2017 19:53:22 +0100 Subject: BASE: Check scanf return value when adding a game --- base/commandLine.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'base/commandLine.cpp') 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"); -- cgit v1.2.3