Skip to content

Commit c6a4e3f

Browse files
committed
Merge branch 'mm/empty-loose-error-message' into maint
* mm/empty-loose-error-message: fsck: give accurate error message on empty loose object files
2 parents f342afa + 33e42de commit c6a4e3f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sha1_file.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,11 @@ void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
12021202

12031203
if (!fstat(fd, &st)) {
12041204
*size = xsize_t(st.st_size);
1205+
if (!*size) {
1206+
/* mmap() is forbidden on empty files */
1207+
error("object file %s is empty", sha1_file_name(sha1));
1208+
return NULL;
1209+
}
12051210
map = xmmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0);
12061211
}
12071212
close(fd);

0 commit comments

Comments
 (0)