]> 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:10:30 +0000 (11:10 +0100)
The bug has been present since 89aa39f394e0fa4935e6cadd7184e372a37f9506
(ccache 3.3).

Fixes #1377.

(cherry picked from commit 432e1f5178631aec14a76f8be82c7e090c45bc69)

src/argprocessing.cpp

index 93046e13a9b00c8b5441ed421b1c39338f8fbcd0..22f135723d4ef43504d03adbb3563b3dcceaf725 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) {