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 /sha1_file.c | |
parent | 39ee1710c071f42741d4324dbb03e4618917734c (diff) | |
parent | 33e42de0d21a8365496e904235bd32fd4659300d (diff) | |
download | git-8c18a6f3fa0b1be98896a6c55c9e56595fbd3f41.tar.gz |
Merge branch 'mm/empty-loose-error-message'
* mm/empty-loose-error-message:
fsck: give accurate error message on empty loose object files
Diffstat (limited to 'sha1_file.c')
-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); |