Closed Bug 1057175 Opened 5 years ago Closed 5 years ago

ABORT: WriteToRasterImage should consume everything or the image must be in error

Categories

(Core :: ImageLib, defect)

x86
macOS
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla34

People

(Reporter: tnikkel, Assigned: tnikkel)

Details

Attachments

(1 file)

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. I suggest checking the return value of the ReadSegments call to fix this.
Attached patch patchSplinter Review
Attachment #8477128 - Flags: review?(seth)
Comment on attachment 8477128 [details] [diff] [review]
patch

Review of attachment 8477128 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good! Thanks for investigating this.

::: image/src/RasterImage.cpp
@@ +1831,5 @@
>    uint32_t bytesRead;
>    rv = aInStr->ReadSegments(WriteToRasterImage, this, aCount, &bytesRead);
>  
> +  NS_ABORT_IF_FALSE(bytesRead == aCount || HasError() || NS_FAILED(rv),
> +    "WriteToRasterImage should consume everything if ReadSegments succeeds or the image must be in error!");

Nit: might be nice to split the string onto two lines.
Attachment #8477128 - Flags: review?(seth) → review+
https://hg.mozilla.org/mozilla-central/rev/5cc6986dffde
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in before you can comment on or make changes to this bug.