diff options
author | William M. Brack <wbrack@src.gnome.org> | 2007-11-13 21:12:50 +0000 |
---|---|---|
committer | William M. Brack <wbrack@src.gnome.org> | 2007-11-13 21:12:50 +0000 |
commit | e27443f210f0264f7addd348d126cf7e29100c87 (patch) | |
tree | ec173f0b67a9efc4f4f024b8e616b9f0b3be0eb8 /libexslt | |
parent | ee016c46d1f6b949703209305362fc1119f569b9 (diff) | |
download | libxslt-e27443f210f0264f7addd348d126cf7e29100c87.tar.gz libxslt-e27443f210f0264f7addd348d126cf7e29100c87.tar.bz2 libxslt-e27443f210f0264f7addd348d126cf7e29100c87.zip |
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
Diffstat (limited to 'libexslt')
-rw-r--r-- | libexslt/common.c | 6 | ||||
-rw-r--r-- | libexslt/dynamic.c | 25 |
2 files changed, 25 insertions, 6 deletions
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: |