Merge pull request #751 from yuslepukhin/return_noerror

Mmap reads should not return error if reading past file
main
Igor Canadi 10 years ago
commit 7bbe10c013
  1. 9
      port/win/env_win.cc

@ -233,13 +233,14 @@ class WinMmapReadableFile : public RandomAccessFile {
char* scratch) const override { char* scratch) const override {
Status s; Status s;
if (offset + n > length_) { if (offset > length_) {
*result = Slice(); *result = Slice();
s = IOError(fileName_, EINVAL); return IOError(fileName_, EINVAL);
} else { } else if (offset + n > length_) {
n = length_ - offset;
}
*result = *result =
Slice(reinterpret_cast<const char*>(mapped_region_) + offset, n); Slice(reinterpret_cast<const char*>(mapped_region_) + offset, n);
}
return s; return s;
} }

Loading…
Cancel
Save