diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-02-12 22:42:02 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-02-12 22:42:02 -0800 |
commit | 8c18a6f3fa0b1be98896a6c55c9e56595fbd3f41 (patch) | |
tree | a375423eb0ad74944fdefc0499acf49ae32c9076 | |
parent | Merge branch 'nk/ctype-for-perf' (diff) | |
parent | fsck: give accurate error message on empty loose object files (diff) | |
download | tgif-8c18a6f3fa0b1be98896a6c55c9e56595fbd3f41.tar.xz |
Merge branch 'mm/empty-loose-error-message'
* mm/empty-loose-error-message:
fsck: give accurate error message on empty loose object files
-rw-r--r-- | sha1_file.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c index 88f2151ff3..d9aa0e0a2c 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1202,6 +1202,11 @@ void *map_sha1_file(const unsigned char *sha1, unsigned long *size) if (!fstat(fd, &st)) { *size = xsize_t(st.st_size); + if (!*size) { + /* mmap() is forbidden on empty files */ + error("object file %s is empty", sha1_file_name(sha1)); + return NULL; + } map = xmmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0); } close(fd); |