Bug 586650 txFnStartOutput leaks qname when qname->init fails
authortimeless@mozdev.org
Wed, 08 Dec 2010 12:28:41 +0000
changeset 58897 048f8f89152b22b77104b80f473a74437d1ac4a4
parent 58896 48a4773a6316b10b953f93ad3d1b842c5c9ca0dd
child 58898 35ea831c27abbe8630b6329bad3a69840a1671f1
push idunknown
push userunknown
push dateunknown
bugs586650
milestone2.0b8pre
Bug 586650 txFnStartOutput leaks qname when qname->init fails r=sicking, a=sicking
content/xslt/src/xslt/txStylesheetCompileHandlers.cpp
--- a/content/xslt/src/xslt/txStylesheetCompileHandlers.cpp
+++ b/content/xslt/src/xslt/txStylesheetCompileHandlers.cpp
@@ -993,25 +993,26 @@ txFnStartOutput(PRInt32 aNamespaceID,
         item->mFormat.mSystemId = attr->mValue;
     }
 
     getStyleAttr(aAttributes, aAttrCount, kNameSpaceID_None,
                  txXSLTAtoms::cdataSectionElements, PR_FALSE, &attr);
     if (attr) {
         nsWhitespaceTokenizer tokens(attr->mValue);
         while (tokens.hasMoreTokens()) {
-            txExpandedName* qname = new txExpandedName();
+            nsAutoPtr<txExpandedName> qname(new txExpandedName());
             NS_ENSURE_TRUE(qname, NS_ERROR_OUT_OF_MEMORY);
 
             rv = qname->init(tokens.nextToken(),
                              aState.mElementContext->mMappings, PR_FALSE);
             NS_ENSURE_SUCCESS(rv, rv);
 
             rv = item->mFormat.mCDATASectionElements.add(qname);
             NS_ENSURE_SUCCESS(rv, rv);
+            qname.forget();
         }
     }
 
     rv = getYesNoAttr(aAttributes, aAttrCount,
                       txXSLTAtoms::indent, PR_FALSE, aState,
                       item->mFormat.mIndent);
     NS_ENSURE_SUCCESS(rv, rv);