From 18046ae92d77753f42bb6e3a6580eb5084ec294e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 24 Jul 2015 12:49:11 -0400 Subject: [PATCH] util: Deliberately initializing confirmation responses inside the loop --- src/util.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 3cd9906a1..c78384262 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -67,8 +67,6 @@ bool confirm (const std::string& question) { std::vector options {STRING_UTIL_CONFIRM_YES, STRING_UTIL_CONFIRM_NO}; - - std::string answer; std::vector matches; do @@ -76,6 +74,7 @@ bool confirm (const std::string& question) std::cout << question << STRING_UTIL_CONFIRM_YN; + std::string answer {""}; std::getline (std::cin, answer); answer = std::cin.eof() ? STRING_UTIL_CONFIRM_NO : lowerCase (trim (answer)); @@ -99,8 +98,6 @@ int confirm4 (const std::string& question) STRING_UTIL_CONFIRM_ALL_U, STRING_UTIL_CONFIRM_ALL, STRING_UTIL_CONFIRM_QUIT}; - - std::string answer; std::vector matches; do @@ -113,6 +110,7 @@ int confirm4 (const std::string& question) << options[5] << ") "; + std::string answer {""}; std::getline (std::cin, answer); answer = trim (answer); autoComplete (answer, options, matches, 1); // Hard-coded 1.