From 0bba26fde522ceb2d4543ea5fa6b8d8bb8a50bc6 Mon Sep 17 00:00:00 2001 From: Kp Date: Tue, 31 May 2016 00:42:56 +0000 Subject: [PATCH] Move ini.pop_back() into ReadIniArgs Both callers of ReadIniArgs need the string removed afterward. Prior to 8fb9a0f, only the parser for `-ini` needed the string removed. The caller for the automatic ini file ended and destroyed the container. As of 8fb9a0f, the container persists. Leaving the string in the container causes a bad error message if the command line is rejected. It is bad form to have ReadIniArgs pop, but the caller push. However, the two callers use different signatures for emplace_back(), so unifying the push would require calling a suboptimal emplace_back. Choose the lesser evil of unbalanced push/pop. Reported-by: zicodxx --- similar/misc/args.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/similar/misc/args.cpp b/similar/misc/args.cpp index 86d766d96..acc377d7e 100644 --- a/similar/misc/args.cpp +++ b/similar/misc/args.cpp @@ -186,6 +186,7 @@ static void ReadIniArgs(Inilist &ini) Arglist Args; AppendIniArgs(ini.back().filename().c_str(), Args); ReadCmdArgs(ini, Args); + ini.pop_back(); } static void ReadCmdArgs(Inilist &ini, Arglist &Args) @@ -393,7 +394,6 @@ static void ReadCmdArgs(Inilist &ini, Arglist &Args) if (ini.size() > 10) throw nesting_depth_exceeded(); ReadIniArgs(ini); - ini.pop_back(); } else throw unhandled_argument(std::move(*pp));