diff --git a/sha1_file.c b/sha1_file.c
index 6b1b5125c8f992927b70ce10c43f2332f5948bc0..f9f8d5e91c278000e5869f49ba6a79ddfaf13145 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
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);