Skip to content

Commit

Permalink
Merge branch 'mm/empty-loose-error-message' into maint
Browse files Browse the repository at this point in the history
* mm/empty-loose-error-message:
  fsck: give accurate error message on empty loose object files
  • Loading branch information
Junio C Hamano committed Feb 16, 2012
2 parents f342afa + 33e42de commit c6a4e3f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c6a4e3f

Please sign in to comment.