diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-02-16 14:00:25 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-02-16 14:00:25 -0800 |
commit | c6a4e3f7a78011bd7c1c75521c6d12ac311513f7 (patch) | |
tree | 93a15aff1b119add8cdfc937c20ffc5bc36bcbf9 | |
parent | Merge branch 'nk/ctype-for-perf' into maint (diff) | |
parent | fsck: give accurate error message on empty loose object files (diff) | |
download | tgif-c6a4e3f7a78011bd7c1c75521c6d12ac311513f7.tar.xz |
Merge branch 'mm/empty-loose-error-message' into maint
* 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); |