Bug 1277752 (part 2) - Check the return value of PR_Seek64() in nsTemporaryFileInputStream::ReadSegments(). r=valentin.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 03 Jun 2016 14:27:22 +1000
changeset 339573 e54065dbe41dc0192f5d1710ad1ba5855f573545
parent 339572 79163ae0b445b0a7eba61cb65bd2c8f35fcf6694
child 339574 eeca7b46a4ed8240f5cd94b77e98d7e6a7b36e14
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1277752
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1277752 (part 2) - Check the return value of PR_Seek64() in nsTemporaryFileInputStream::ReadSegments(). r=valentin.
netwerk/base/nsTemporaryFileInputStream.cpp
--- a/netwerk/base/nsTemporaryFileInputStream.cpp
+++ b/netwerk/base/nsTemporaryFileInputStream.cpp
@@ -54,17 +54,20 @@ nsTemporaryFileInputStream::ReadSegments
   NS_ASSERTION(mCurPos <= mEndPos, "bad stream state");
   *result = 0;
 
   if (mClosed) {
     return NS_BASE_STREAM_CLOSED;
   }
 
   mozilla::MutexAutoLock lock(mFileDescOwner->FileMutex());
-  PR_Seek64(mFileDescOwner->mFD, mCurPos, PR_SEEK_SET);
+  int64_t offset = PR_Seek64(mFileDescOwner->mFD, mCurPos, PR_SEEK_SET);
+  if (offset == -1) {
+    return NS_ErrorAccordingToNSPR();
+  }
 
   // Limit requested count to the amount remaining in our section of the file.
   count = std::min(count, uint32_t(mEndPos - mCurPos));
 
   char buf[4096];
   while (*result < count) {
     uint32_t bufCount = std::min(count - *result, (uint32_t) sizeof(buf));
     int32_t bytesRead = PR_Read(mFileDescOwner->mFD, buf, bufCount);