From 653977cec758514027a0c73937b781f60c18ced9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 26 Nov 2017 18:14:43 +0100 Subject: [PATCH] UICommon: Fix unsafe usage of optparse::Values::all The const-qualified all() member method triggers undefined behaviour if the option passed to it is not set. --- Source/Core/UICommon/CommandLineParse.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/UICommon/CommandLineParse.cpp b/Source/Core/UICommon/CommandLineParse.cpp index e8cdc6b3b6..1ca4bb90e8 100644 --- a/Source/Core/UICommon/CommandLineParse.cpp +++ b/Source/Core/UICommon/CommandLineParse.cpp @@ -107,9 +107,9 @@ std::unique_ptr CreateParser(ParserOptions options) static void AddConfigLayer(const optparse::Values& options) { - const std::list& config_args = options.all("config"); - if (!config_args.empty()) + if (options.is_set_by_user("config")) { + const std::list& config_args = options.all("config"); Config::AddLayer(std::make_unique( config_args, static_cast(options.get("video_backend")), static_cast(options.get("audio_emulation"))));