Bug 1057175. If ReadSegments returns a failure code it might not send any data to RasterImage, so check for return value. r=seth

We can hit this if the input stream gets closed before we can read from it. In the case I debugged the image was removed from the DOM (by having it's containing document removed from the DOM) so it's request was cancelled. ReadSegments on a closed stream (at least a cache file input stream) just returns and does nothing.
This commit is contained in:
Timothy Nikkel 2014-08-23 23:47:55 -05:00
parent c01928b7fa
commit bcdf20a757

View File

@ -1822,8 +1822,9 @@ RasterImage::OnImageDataAvailable(nsIRequest*,
uint32_t bytesRead;
rv = aInStr->ReadSegments(WriteToRasterImage, this, aCount, &bytesRead);
NS_ABORT_IF_FALSE(bytesRead == aCount || HasError(),
"WriteToRasterImage should consume everything or the image must be in error!");
NS_ABORT_IF_FALSE(bytesRead == aCount || HasError() || NS_FAILED(rv),
"WriteToRasterImage should consume everything if ReadSegments succeeds or "
"the image must be in error!");
return rv;
}