summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-02-16 14:00:25 -0800
committerJunio C Hamano <gitster@pobox.com>2012-02-16 14:00:25 -0800
commitc6a4e3f7a78011bd7c1c75521c6d12ac311513f7 (patch)
tree93a15aff1b119add8cdfc937c20ffc5bc36bcbf9 /sha1_file.c
parentf342afafceb16b29a9b8718c5f42afaaf6291d78 (diff)
parent33e42de0d21a8365496e904235bd32fd4659300d (diff)
downloadgit-c6a4e3f7a78011bd7c1c75521c6d12ac311513f7.tar.gz
Merge branch 'mm/empty-loose-error-message' into maint
* 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);