]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Avoid reading bad memory when using the "ccache compiler" form
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 13 May 2012 14:35:38 +0000 (16:35 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 13 May 2012 14:35:38 +0000 (16:35 +0200)
This regression was introduced in 469267b2be49d6acdca5058e3e744a508ce3da5d.

ccache.c

index 69b814c95febcd9ce0be9ef66ab8b536b3a13f61..f793fc82b5557518697d49f09644bd50e7b2cbc5 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1315,13 +1315,12 @@ from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest)
 /* find the real compiler. We just search the PATH to find a executable of the
    same name that isn't a link to ourselves */
 static void
-find_compiler(void)
+find_compiler(char** argv)
 {
        char *base;
        char *compiler;
-       const char *orig_first_argument = orig_args->argv[0];
 
-       base = basename(orig_args->argv[0]);
+       base = basename(argv[0]);
 
        /* we might be being invoked like "ccache gcc -c foo.c" */
        if (same_executable_name(base, MYNAME)) {
@@ -1346,7 +1345,7 @@ find_compiler(void)
                stats_update(STATS_COMPILER);
                fatal("Could not find compiler \"%s\" in PATH", base);
        }
-       if (str_eq(compiler, orig_first_argument)) {
+       if (str_eq(compiler, argv[0])) {
                fatal("Recursive invocation (the name of the ccache binary must be \"%s\")",
                      MYNAME);
        }
@@ -2143,7 +2142,7 @@ ccache(int argc, char *argv[])
        orig_args = args_init(argc, argv);
 
        initialize();
-       find_compiler();
+       find_compiler(argv);
 
        if (!str_eq(conf->log_file, "")) {
                conf_print_items(conf, configuration_logger, NULL);