]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Avoid crash for -arch as last compiler option
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 6 Jan 2024 19:21:44 +0000 (20:21 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 7 Jan 2024 10:06:36 +0000 (11:06 +0100)
The bug has been present since 89aa39f394e0fa4935e6cadd7184e372a37f9506
(ccache 3.3).

Fixes #1377.

src/argprocessing.cpp

index d1fbae52612dd25ef1759e8a60144eeaa2873981..b08fac754af801cf95c97fe450798e90dece0231 100644 (file)
@@ -426,6 +426,10 @@ process_option_arg(const Context& ctx,
 
   // Handle -arch options.
   if (arg == "-arch") {
+    if (i == args.size() - 1) {
+      LOG("Missing argument to {}", args[i]);
+      return Statistic::bad_compiler_arguments;
+    }
     ++i;
     args_info.arch_args.emplace_back(args[i]);
     if (args_info.arch_args.size() == 2) {