summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-02-12 22:42:02 -0800
committerJunio C Hamano <gitster@pobox.com>2012-02-12 22:42:02 -0800
commit8c18a6f3fa0b1be98896a6c55c9e56595fbd3f41 (patch)
treea375423eb0ad74944fdefc0499acf49ae32c9076 /sha1_file.c
parent39ee1710c071f42741d4324dbb03e4618917734c (diff)
parent33e42de0d21a8365496e904235bd32fd4659300d (diff)
downloadgit-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.c5
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);