From d45a55885c3437baa836a35224d8881f8bbff57a Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sat, 4 Feb 2023 15:33:45 +0100 Subject: fix: Don't read first character of empty strings --- src/argprocessing.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index 331bc904..f7f68007 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -268,7 +268,7 @@ std::string make_dash_option(const Config& config, const std::string& arg) { std::string new_arg = arg; - if (config.is_compiler_group_msvc() && arg[0] == '/') { + if (config.is_compiler_group_msvc() && util::starts_with(arg, "/")) { // MSVC understands both /option and -option, so convert all /option to // -option to simplify our handling. new_arg[0] = '-'; @@ -303,7 +303,7 @@ process_option_arg(const Context& ctx, std::string arg = make_dash_option(ctx.config, args[i]); // Exit early if we notice a non-option argument right away. - if (arg[0] != '-' && arg[0] != '@') { + if (arg.empty() || (arg[0] != '-' && arg[0] != '@')) { return std::nullopt; } -- cgit v1.2.1