Bug 1333384 - nsTemporaryFileInputStream::ReadSegments must consider the stream as closed if PR_Read() return 0. r=bkelly, a=ritu
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 24 Jan 2017 16:02:15 +0100
changeset 378094 41325adb5477a84e8353c40c93ab717b357ec984
parent 378093 195972ebe7a1a1b1b0b4882a7735f137cd09e75f
child 378095 9df75a609fd44c8b4ae337b283b01ec9a1309b5f
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly, ritu
bugs1333384
milestone53.0a2
Bug 1333384 - nsTemporaryFileInputStream::ReadSegments must consider the stream as closed if PR_Read() return 0. r=bkelly, a=ritu
netwerk/base/nsTemporaryFileInputStream.cpp
--- a/netwerk/base/nsTemporaryFileInputStream.cpp
+++ b/netwerk/base/nsTemporaryFileInputStream.cpp
@@ -79,16 +79,21 @@ nsTemporaryFileInputStream::ReadSegments
 
   // 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);
+    if (bytesRead == 0) {
+      mClosed = true;
+      return NS_OK;
+    }
+
     if (bytesRead < 0) {
       return NS_ErrorAccordingToNSPR();
     }
 
     int32_t bytesWritten = 0;
     while (bytesWritten < bytesRead) {
       uint32_t writerCount = 0;
       nsresult rv = writer(this, closure, buf + bytesWritten, *result,