Bug 586603 HTMLContentSink::BeginContext should null check mCurrentContext before creating sc
authortimeless@mozdev.org
Tue, 22 Mar 2011 11:17:44 -0400
changeset 63640 d7cbfae806d9889afd145c50c7ea235eeffca5ad
parent 63639 85eb53e80ce1872292d6510c906e60d1c53333fe
child 63641 60e1f37ed71991cd70c752e0dd91e374eabdfb77
push id19248
push usereakhgari@mozilla.com
push dateWed, 23 Mar 2011 23:19:35 +0000
treeherdermozilla-central@ab95ab9e389b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs586603
milestone2.0b13pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 586603 HTMLContentSink::BeginContext should null check mCurrentContext before creating sc r=smaug
content/html/document/src/nsHTMLContentSink.cpp
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -1757,22 +1757,16 @@ HTMLContentSink::IsFormOnStack()
   return mFormOnStack;
 }
 
 NS_IMETHODIMP
 HTMLContentSink::BeginContext(PRInt32 aPosition)
 {
   NS_PRECONDITION(aPosition > -1, "out of bounds");
 
-  // Create new context
-  SinkContext* sc = new SinkContext(this);
-  if (!sc) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   if (!mCurrentContext) {
     NS_ERROR("Nonexistent context");
 
     return NS_ERROR_FAILURE;
   }
 
   // Flush everything in the current context so that we don't have
   // to worry about insertions resulting in inconsistent frame creation.
@@ -1790,16 +1784,17 @@ HTMLContentSink::BeginContext(PRInt32 aP
 
   // If the content under which the new context is created
   // has a child on the stack, the insertion point is
   // before the last child.
   if (aPosition < (mCurrentContext->mStackPos - 1)) {
     insertionPoint = content->GetChildCount() - 1;
   }
 
+  SinkContext* sc = new SinkContext(this);
   sc->Begin(nodeType,
             content,
             mCurrentContext->mStack[aPosition].mNumFlushed,
             insertionPoint);
   NS_ADDREF(sc->mSink);
 
   mContextStack.AppendElement(mCurrentContext);
   mCurrentContext = sc;