Permalink
Browse files

Fixed delta updates bug wherein updates fail on empty file.

mmap()ing empty files caused EINVAL to be returned and _hashOfFile
would return an incorrect result. This has been rectified.
  • Loading branch information...
1 parent a8f26b1 commit e2a59fccb26c6b4572ebe55e450b74c0a006533b @aidansteele aidansteele committed with andymatuschak Aug 23, 2010
Showing with 5 additions and 0 deletions.
  1. +5 −0 SUBinaryDeltaCommon.m
View
@@ -78,6 +78,11 @@ static void _hashOfFile(unsigned char* hash, FTSENT *ent)
}
size_t fileSize = (size_t)ent->fts_statp->st_size;
+ if (fileSize == 0) {
+ _hashOfBuffer(hash, NULL, 0);
+ return;
+ }
+
void *buffer = mmap(0, fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
if (buffer == (void*)-1) {
close(fileDescriptor);

0 comments on commit e2a59fc

Please sign in to comment.