Bug 1336832 - Properly delete pushed eval contexts, r=erahm, a=lizzard.
authorPeter Van der Beken <peterv@propagandism.org>
Wed, 22 Feb 2017 11:54:13 +0100
changeset 379256 6188b6cab49e2bfa036b24d8112cda5f5f9416f0
parent 379255 cc44bcedcee257bdc94c1d20e1b68e9e025a3e0f
child 379257 1b0b9e1915d147b4e904ac07a5f16677035600ce
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm, lizzard
bugs1336832
milestone53.0
Bug 1336832 - Properly delete pushed eval contexts, r=erahm, a=lizzard.
dom/xslt/xslt/txExecutionState.cpp
dom/xslt/xslt/txExecutionState.h
dom/xslt/xslt/txInstructions.cpp
--- a/dom/xslt/xslt/txExecutionState.cpp
+++ b/dom/xslt/xslt/txExecutionState.cpp
@@ -158,16 +158,27 @@ txExecutionState::end(nsresult aResult)
     }
     else if (!mOutputHandler) {
         return NS_OK;
     }
     return mOutputHandler->endDocument(aResult);
 }
 
 void
+txExecutionState::popAndDeleteEvalContext()
+{
+  if (!mEvalContextStack.isEmpty()) {
+    auto ctx = popEvalContext();
+    if (ctx != mInitialEvalContext) {
+      delete ctx;
+    }
+  }
+}
+
+void
 txExecutionState::popAndDeleteEvalContextUntil(txIEvalContext* aContext)
 {
   auto ctx = popEvalContext();
   while (ctx && ctx != aContext) {
     MOZ_RELEASE_ASSERT(ctx != mInitialEvalContext);
     delete ctx;
     ctx = popEvalContext();
   }
--- a/dom/xslt/xslt/txExecutionState.h
+++ b/dom/xslt/xslt/txExecutionState.h
@@ -90,16 +90,18 @@ public:
         nsCOMPtr<nsIAtom> mModeLocalName;
         txVariableMap* mParams;
     };
 
     // Stack functions
     nsresult pushEvalContext(txIEvalContext* aContext);
     txIEvalContext* popEvalContext();
 
+    void popAndDeleteEvalContext();
+
     /**
      * Helper that deletes all entries before |aContext| and then
      * pops it off the stack. The caller must delete |aContext| if
      * desired.
      */
     void popAndDeleteEvalContextUntil(txIEvalContext* aContext);
 
     nsresult pushBool(bool aBool);
--- a/dom/xslt/xslt/txInstructions.cpp
+++ b/dom/xslt/xslt/txInstructions.cpp
@@ -465,17 +465,17 @@ txLoopNodeSet::txLoopNodeSet(txInstructi
 
 nsresult
 txLoopNodeSet::execute(txExecutionState& aEs)
 {
     aEs.popTemplateRule();
     txNodeSetContext* context =
         static_cast<txNodeSetContext*>(aEs.getEvalContext());
     if (!context->hasNext()) {
-        delete aEs.popEvalContext();
+        aEs.popAndDeleteEvalContext();
 
         return NS_OK;
     }
 
     context->next();
     aEs.gotoInstruction(mTarget);
     
     return NS_OK;