Bug 1290293 - Part 2f. Assert there is no frame on the finish decoding error path. r=tnikkel draft
authorAndrew Osmond <aosmond@mozilla.com>
Fri, 10 Feb 2017 08:33:11 -0500
changeset 485884 8ccc7795b51bdefaf14050a4919d975146568470
parent 485883 defc9f9bee5e1305b970be57c80345b3b3633105
child 485885 1d0c76861cee46374a59ce848c539bfa11c4555d
push id45870
push userbmo:kechen@mozilla.com
push dateFri, 17 Feb 2017 09:36:54 +0000
reviewerstnikkel
bugs1290293
milestone54.0a1
Bug 1290293 - Part 2f. Assert there is no frame on the finish decoding error path. r=tnikkel
image/Decoder.cpp
image/decoders/nsICODecoder.cpp
--- a/image/Decoder.cpp
+++ b/image/Decoder.cpp
@@ -375,17 +375,22 @@ Decoder::AllocateFrameInternal(uint32_t 
 
 /*
  * Hook stubs. Override these as necessary in decoder implementations.
  */
 
 nsresult Decoder::InitInternal() { return NS_OK; }
 nsresult Decoder::BeforeFinishInternal() { return NS_OK; }
 nsresult Decoder::FinishInternal() { return NS_OK; }
-nsresult Decoder::FinishWithErrorInternal() { return NS_OK; }
+
+nsresult Decoder::FinishWithErrorInternal()
+{
+  MOZ_ASSERT(!mInFrame);
+  return NS_OK;
+}
 
 /*
  * Progress Notifications
  */
 
 void
 Decoder::PostSize(int32_t aWidth,
                   int32_t aHeight,
--- a/image/decoders/nsICODecoder.cpp
+++ b/image/decoders/nsICODecoder.cpp
@@ -74,16 +74,18 @@ nsICODecoder::FinishInternal()
   MOZ_ASSERT(!HasError(), "Shouldn't call FinishInternal after error!");
 
   return GetFinalStateFromContainedDecoder();
 }
 
 nsresult
 nsICODecoder::FinishWithErrorInternal()
 {
+  // No need to assert !mInFrame here because this condition is enforced by
+  // mContainedDecoder.
   return GetFinalStateFromContainedDecoder();
 }
 
 nsresult
 nsICODecoder::GetFinalStateFromContainedDecoder()
 {
   if (!mContainedDecoder) {
     return NS_OK;