# HG changeset patch # User Nick Wellnhofer <wellnhofer@aevum.de> # Date 1654516906 -7200 # Mon Jun 06 14:01:46 2022 +0200 # Node ID b2f0a9697ba8967d12d98f2022b1c7f3972ea354 # Parent 564229366f81abe571a4d7f8a2b51154e3cc1b2b Fix quadratic behavior with variables and parameters Backup and restore "lasttext" state when evaluating variables or template parameters. Otherwise, appending multiple text nodes would lead to quadratic behavior. Fixes #70. diff --git a/libxslt/variables.c b/libxslt/variables.c --- a/libxslt/variables.c +++ b/libxslt/variables.c @@ -963,6 +963,8 @@ xmlDocPtr container; xmlNodePtr oldInsert; xmlDocPtr oldOutput; + const xmlChar *oldLastText; + int oldLastTextSize, oldLastTextUse; xsltStackElemPtr oldVar = ctxt->contextVariable; /* @@ -988,6 +990,9 @@ oldOutput = ctxt->output; oldInsert = ctxt->insert; + oldLastText = ctxt->lasttext; + oldLastTextSize = ctxt->lasttsize; + oldLastTextUse = ctxt->lasttuse; ctxt->output = container; ctxt->insert = (xmlNodePtr) container; @@ -1002,6 +1007,9 @@ ctxt->contextVariable = oldVar; ctxt->insert = oldInsert; ctxt->output = oldOutput; + ctxt->lasttext = oldLastText; + ctxt->lasttsize = oldLastTextSize; + ctxt->lasttuse = oldLastTextUse; result = xmlXPathNewValueTree((xmlNodePtr) container); }