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.
This commit is contained in:
Léo Lam 2017-11-26 18:14:43 +01:00
parent 60afb1d1b4
commit 653977cec7
1 changed files with 2 additions and 2 deletions

View File

@ -107,9 +107,9 @@ std::unique_ptr<optparse::OptionParser> CreateParser(ParserOptions options)
static void AddConfigLayer(const optparse::Values& options)
{
const std::list<std::string>& config_args = options.all("config");
if (!config_args.empty())
if (options.is_set_by_user("config"))
{
const std::list<std::string>& config_args = options.all("config");
Config::AddLayer(std::make_unique<CommandLineConfigLayerLoader>(
config_args, static_cast<const char*>(options.get("video_backend")),
static_cast<const char*>(options.get("audio_emulation"))));