]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Treat zero length object files as invalid
authorMichael Meeks <michael.meeks@suse.com>
Thu, 8 Aug 2013 20:07:27 +0000 (22:07 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 8 Aug 2013 20:07:27 +0000 (22:07 +0200)
Fix for bug 9972.

ccache.c

index c02868fcfa75f15396258084ae620342a27715c3..b20c087bcdd19d07eb586bdcc910fdb73af36add 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1105,6 +1105,16 @@ from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest)
                return;
        }
 
+       /*
+        * Occasionally, e.g. on hard reset, our cache ends up as just filesystem
+        * meta-data with no content catch an easy case of this.
+        */
+       if (st.st_size == 0) {
+               cc_log("Invalid (empty) object file %s in cache", cached_obj);
+               x_unlink(cached_obj);
+               return;
+       }
+
        /*
         * (If mode != FROMCACHE_DIRECT_MODE, the dependency file is created by
         * gcc.)