Make Sourcebuffer::AppendFromInputStream handle canceled image loads.

This commit is contained in:
wolfbeast 2019-01-21 14:02:56 +01:00 committed by Roy Tam
commit 3640321580

View file

@ -451,10 +451,18 @@ SourceBuffer::AppendFromInputStream(nsIInputStream* aInputStream,
uint32_t bytesRead;
nsresult rv = aInputStream->ReadSegments(AppendToSourceBuffer, this,
aCount, &bytesRead);
if (!NS_WARN_IF(NS_FAILED(rv))) {
MOZ_ASSERT(bytesRead == aCount,
"AppendToSourceBuffer should consume everything");
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (bytesRead == 0) {
// The loading of the image has been canceled.
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(bytesRead == aCount,
"AppendToSourceBuffer should consume everything");
return rv;
}