summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam M. Brack <wbrack@src.gnome.org>2007-11-13 21:12:50 +0000
committerWilliam M. Brack <wbrack@src.gnome.org>2007-11-13 21:12:50 +0000
commite27443f210f0264f7addd348d126cf7e29100c87 (patch)
treeec173f0b67a9efc4f4f024b8e616b9f0b3be0eb8
parentee016c46d1f6b949703209305362fc1119f569b9 (diff)
downloadlibxslt-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
-rw-r--r--ChangeLog7
-rw-r--r--libexslt/common.c6
-rw-r--r--libexslt/dynamic.c25
3 files changed, 32 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f689666..8f1ae36c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Nov 13 13:08:08 PDT 2007 William Brack <wbrack@mmm.com.hk>
+
+ * 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).
+
Mon Nov 12 13:53:58 PDT 2007 William Brack <wbrack@mmm.com.hk>
* libexslt/strings.c: Added code to mark the results of
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: