From e27443f210f0264f7addd348d126cf7e29100c87 Mon Sep 17 00:00:00 2001 From: "William M. Brack" Date: Tue, 13 Nov 2007 21:12:50 +0000 Subject: After discussion on Bugzilla with Peter Pawlowski, added same code for * libexslt/common.c, libexslt/dynamic.c: After discussion on Bugzilla with Peter Pawlowski, added same code for preventing deletion of function result during garbage collection (see bug #495995). svn path=/trunk/; revision=1449 --- libexslt/common.c | 6 ++++++ libexslt/dynamic.c | 25 +++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'libexslt') diff --git a/libexslt/common.c b/libexslt/common.c index ba57fa5b..77f352e5 100644 --- a/libexslt/common.c +++ b/libexslt/common.c @@ -60,6 +60,12 @@ exsltNodeSetFunction (xmlXPathParserContextPtr ctxt, int nargs) { xsltTransformError(tctxt, NULL, tctxt->inst, "exsltNodeSetFunction: Failed to create a node set object.\n"); tctxt->state = XSLT_STATE_STOPPED; + } else { + /* + * Mark it as a function result in order to avoid garbage + * collecting of tree fragments + */ + xsltExtensionInstructionResultRegister(tctxt, obj); } if (strval != NULL) xmlFree (strval); diff --git a/libexslt/dynamic.c b/libexslt/dynamic.c index 11c291b0..607860b1 100644 --- a/libexslt/dynamic.c +++ b/libexslt/dynamic.c @@ -98,9 +98,10 @@ exsltDynMapFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlChar *str = NULL; xmlNodeSetPtr nodeset = NULL; + xsltTransformContextPtr tctxt; xmlXPathCompExprPtr comp = NULL; xmlXPathObjectPtr ret = NULL; - xmlDocPtr oldDoc, container; + xmlDocPtr oldDoc, container = NULL; xmlNodePtr oldNode; int oldContextSize; int oldProximityPosition; @@ -134,7 +135,7 @@ exsltDynMapFunction(xmlXPathParserContextPtr ctxt, int nargs) ret = xmlXPathNewNodeSet(NULL); if (ret == NULL) { xsltGenericError(xsltGenericErrorContext, - "exsltDynMapFunctoin: ret == NULL\n"); + "exsltDynMapFunction: ret == NULL\n"); goto cleanup; } @@ -147,10 +148,19 @@ exsltDynMapFunction(xmlXPathParserContextPtr ctxt, int nargs) * since we really don't know we're going to be adding node(s) * down the road we create the RVT regardless */ - container = xsltCreateRVT(xsltXPathGetTransformContext(ctxt)); - if (container != NULL) - xsltRegisterLocalRVT(xsltXPathGetTransformContext(ctxt), container); - + tctxt = xsltXPathGetTransformContext(ctxt); + if (tctxt == NULL) { + xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL, + "dyn:map : internal error tctxt == NULL\n"); + goto cleanup; + } + container = xsltCreateRVT(tctxt); + if (container == NULL) { + xsltTransformError(tctxt, NULL, NULL, + "dyn:map : internal error container == NULL\n"); + goto cleanup; + } + xsltRegisterLocalRVT(tctxt, container); if (nodeset && nodeset->nodeNr > 0) { xmlXPathNodeSetSort(nodeset); ctxt->context->contextSize = nodeset->nodeNr; @@ -189,6 +199,7 @@ exsltDynMapFunction(xmlXPathParserContextPtr ctxt, int nargs) xmlXPathNodeSetAddUnique(ret->nodesetval, cur); } + xsltExtensionInstructionResultRegister(tctxt, ret); } break; case XPATH_NUMBER: @@ -211,6 +222,7 @@ exsltDynMapFunction(xmlXPathParserContextPtr ctxt, int nargs) xmlXPathNodeSetAddUnique(ret->nodesetval, cur); } + xsltExtensionInstructionResultRegister(tctxt, ret); } break; case XPATH_STRING: @@ -228,6 +240,7 @@ exsltDynMapFunction(xmlXPathParserContextPtr ctxt, int nargs) xmlXPathNodeSetAddUnique(ret->nodesetval, cur); } + xsltExtensionInstructionResultRegister(tctxt, ret); } break; default: -- cgit v1.2.3