]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix deletion of tmp_stderr in depend mode
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 21 Mar 2019 21:04:22 +0000 (22:04 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 21 Mar 2019 21:04:22 +0000 (22:04 +0100)
If the compiler produced stderr, a temporary file leaks if depend mode
is enabled. Also, if the compiler does not produce stderr and depend
mode is enable, an unnecessary unlink is attempted.

Fix this by restructuring logic related to deletion of the temporary
file.

src/ccache.c

index c3597de44417f0e609c54f5a7375264ecd75a132..0bd683fb337e5b9244ae59516aa61f3afc14c560 100644 (file)
@@ -1506,12 +1506,12 @@ to_cache(struct args *args, struct hash *depend_mode_hash)
                } else {
                        copy_file_to_cache(tmp_stderr, cached_stderr);
                }
-       } else {
+       } else if (conf->recache) {
+               // If recaching, we need to remove any previous .stderr.
+               x_unlink(cached_stderr);
+       }
+       if (st.st_size == 0 || conf->depend_mode) {
                tmp_unlink(tmp_stderr);
-               if (conf->recache) {
-                       // If recaching, we need to remove any previous .stderr.
-                       x_unlink(cached_stderr);
-               }
        }
 
        copy_file_to_cache(output_obj, cached_obj);