From: Michael Meeks Date: Thu, 8 Aug 2013 20:07:27 +0000 (+0200) Subject: Treat zero length object files as invalid X-Git-Tag: v3.1.10~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12e2badf739244dc97cad84a6fb1905ec3c4a76d;p=thirdparty%2Fccache.git Treat zero length object files as invalid Fix for bug 9972. --- diff --git a/ccache.c b/ccache.c index c02868fcf..b20c087bc 100644 --- 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.)