Backed out changeset 667c1a306797 (bug 1311687) for heap-use-after-free in txExecutionState.cpp. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 30 Nov 2016 00:39:34 +0100
changeset 324757 a3c15e0b3c4ca1a8f3f3cae1e35bdae18696f6f3
parent 324756 c90a24c73ffff6e6302d7c040f3bdd7457fe1871
child 324758 539af8b2ccc96cfb689534178b1e59cd9cf8ba95
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbackout
bugs1311687
milestone53.0a1
backs out667c1a30679730fbf513e310b2768bc8eea5cc51
Backed out changeset 667c1a306797 (bug 1311687) for heap-use-after-free in txExecutionState.cpp. r=backout
dom/xslt/xslt/txExecutionState.cpp
--- a/dom/xslt/xslt/txExecutionState.cpp
+++ b/dom/xslt/xslt/txExecutionState.cpp
@@ -222,57 +222,43 @@ txExecutionState::getVariable(int32_t aN
     // evaluate the global variable
     pushEvalContext(mInitialEvalContext);
     if (var->mExpr) {
         txVariableMap* oldVars = mLocalVariables;
         mLocalVariables = nullptr;
         rv = var->mExpr->evaluate(getEvalContext(), &aResult);
         mLocalVariables = oldVars;
 
-        if (NS_FAILED(rv)) {
-          popEvalContext();
-          return rv;
-        }
+        NS_ENSURE_SUCCESS(rv, rv);
     }
     else {
         nsAutoPtr<txRtfHandler> rtfHandler(new txRtfHandler);
+        NS_ENSURE_TRUE(rtfHandler, NS_ERROR_OUT_OF_MEMORY);
 
         rv = pushResultHandler(rtfHandler);
-        if (NS_FAILED(rv)) {
-          popEvalContext();
-          return rv;
-        }
-
+        NS_ENSURE_SUCCESS(rv, rv);
+        
         rtfHandler.forget();
 
         txInstruction* prevInstr = mNextInstruction;
         // set return to nullptr to stop execution
         mNextInstruction = nullptr;
         rv = runTemplate(var->mFirstInstruction);
-        if (NS_FAILED(rv)) {
-          popEvalContext();
-          return rv;
-        }
+        NS_ENSURE_SUCCESS(rv, rv);
 
         pushTemplateRule(nullptr, txExpandedName(), nullptr);
         rv = txXSLTProcessor::execute(*this);
-        if (NS_FAILED(rv)) {
-          popEvalContext();
-          return rv;
-        }
+        NS_ENSURE_SUCCESS(rv, rv);
 
         popTemplateRule();
 
         mNextInstruction = prevInstr;
         rtfHandler = (txRtfHandler*)popResultHandler();
         rv = rtfHandler->getAsRTF(&aResult);
-        if (NS_FAILED(rv)) {
-          popEvalContext();
-          return rv;
-        }
+        NS_ENSURE_SUCCESS(rv, rv);
     }
     popEvalContext();
 
     // Remove the placeholder and insert the calculated value
     mGlobalVariableValues.removeVariable(name);
     rv = mGlobalVariableValues.bindVariable(name, aResult);
     if (NS_FAILED(rv)) {
         NS_RELEASE(aResult);