Bug 1311687 - Pop eval context on early returns. r=peterv

Make sure the eval context stack is cleaned up on failure.

MozReview-Commit-ID: AUNen1xt9He

--HG--
extra : rebase_source : 405afaf2e3e77a2fb4761440f837645cf5a8c18e
This commit is contained in:
Eric Rahm 2016-11-07 10:31:50 -08:00
Родитель 6dabfdba6b
Коммит c839abc03c
1 изменённых файлов: 21 добавлений и 7 удалений

Просмотреть файл

@ -227,33 +227,47 @@ txExecutionState::getVariable(int32_t aNamespace, nsIAtom* aLName,
rv = var->mExpr->evaluate(getEvalContext(), &aResult);
mLocalVariables = oldVars;
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
popEvalContext();
return rv;
}
}
else {
nsAutoPtr<txRtfHandler> rtfHandler(new txRtfHandler);
NS_ENSURE_TRUE(rtfHandler, NS_ERROR_OUT_OF_MEMORY);
rv = pushResultHandler(rtfHandler);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
popEvalContext();
return rv;
}
rtfHandler.forget();
txInstruction* prevInstr = mNextInstruction;
// set return to nullptr to stop execution
mNextInstruction = nullptr;
rv = runTemplate(var->mFirstInstruction);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
popEvalContext();
return rv;
}
pushTemplateRule(nullptr, txExpandedName(), nullptr);
rv = txXSLTProcessor::execute(*this);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
popEvalContext();
return rv;
}
popTemplateRule();
mNextInstruction = prevInstr;
rtfHandler = (txRtfHandler*)popResultHandler();
rv = rtfHandler->getAsRTF(&aResult);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
popEvalContext();
return rv;
}
}
popEvalContext();