mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-08-07 10:42:55 +03:00
Fix EXSLT functions returning RVTs from outer scopes
The RVTs referenced from function results must not be blindly registered as local, as they might be part of variables from an outer scope. Remove LOCAL/VARIABLE distinction for RVTs. Don't register as local RVT unconditionally when reflagging as LOCAL. Instead, register function result RVTs from inner variables as local RVTs when they're released in xsltFreeStackElem. Keep local function result RVTs xsltReleaseLocalRVTs instead of reregistering. Closes: https://gitlab.gnome.org/GNOME/libxslt/issues/2 Thanks to Daniel Mendler and Martin Gieseking for the reports.
This commit is contained in:
@@ -426,7 +426,15 @@ exsltFuncFunctionFunction (xmlXPathParserContextPtr ctxt, int nargs) {
|
||||
}
|
||||
}
|
||||
/*
|
||||
* actual processing
|
||||
* Actual processing. Note that contextVariable is set to NULL which
|
||||
* means that RVTs returned from functions always end up as local RVTs,
|
||||
* not as variable fragments if the function is called in the select
|
||||
* expression of an xsl:variable. This is a hack that only works because
|
||||
* xsltReleaseLocalRVTs isn't called after processing xsl:variable.
|
||||
*
|
||||
* It would probably be better to remove the fragile contextVariable
|
||||
* logic and make xsltEvalVariable move the required RVTs into the
|
||||
* variable manually.
|
||||
*/
|
||||
fake = xmlNewDocNode(tctxt->output, NULL,
|
||||
(const xmlChar *)"fake", NULL);
|
||||
@@ -766,6 +774,7 @@ exsltFuncResultElem (xsltTransformContextPtr ctxt,
|
||||
return;
|
||||
}
|
||||
/* Mark as function result. */
|
||||
xsltRegisterLocalRVT(ctxt, container);
|
||||
container->psvi = XSLT_RVT_FUNC_RESULT;
|
||||
|
||||
oldInsert = ctxt->insert;
|
||||
|
Reference in New Issue
Block a user