author | Junio C Hamano <gitster@pobox.com> | |
Mon, 13 Feb 2012 06:42:02 +0000 (22:42 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 13 Feb 2012 06:42:02 +0000 (22:42 -0800) |
* mm/empty-loose-error-message:
fsck: give accurate error message on empty loose object files
fsck: give accurate error message on empty loose object files
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index 88f2151ff31870138a53e40f99f5ae9928b09545..d9aa0e0a2cd45acbbe3beb6c015f5f9071a22902 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);