From 12e2badf739244dc97cad84a6fb1905ec3c4a76d Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Thu, 8 Aug 2013 22:07:27 +0200 Subject: [PATCH] Treat zero length object files as invalid Fix for bug 9972. --- ccache.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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.) -- 2.47.2