From: Joel Rosdahl Date: Sat, 4 Feb 2023 14:33:45 +0000 (+0100) Subject: fix: Don't read first character of empty strings X-Git-Tag: v4.8~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d45a55885c3437baa836a35224d8881f8bbff57a;p=thirdparty%2Fccache.git fix: Don't read first character of empty strings --- diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index 331bc9045..f7f680075 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; }