diff --git a/sha1_file.c b/sha1_file.c
index 25f6965294fcc6bc440eda32187e0cc2b67e69d1..797b0634cefc1a354b4c6619461e483c64adc9af 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);