Subject: | [PATCH] XML-LibXSLT-1.68: set owner when making a copy of a node |
Date: | Tue, 11 Nov 2008 19:44:04 -0800 |
To: | bug-XML-LibXSLT [...] rt.cpan.org, Petr Pajas <pajas [...] matfyz.cz> |
From: | Jim Radford <radford [...] blackbean.org> |
Hi Petr,
I was getting segfaults in XML-LibXSLT-1.68 which I tracked down to my
attribute's document being freed before the attribute itself. When
making a copy of a node in LibXSLT_generic_function we need to bump
the reference count on the document proxy just like is done in
LibXML_generic_extension_function.
Thanks for your work on these modules!
Sincerely,
-Jim
--- XML-LibXSLT-1.68/LibXSLT.xs~ 2008-11-05 05:19:41.000000000 -0800
+++ XML-LibXSLT-1.68/LibXSLT.xs 2008-11-11 19:29:28.000000000 -0800
@@ -282,10 +282,17 @@
(const char *)cls,
(void *)xmlCopyNamespace((xmlNsPtr)tnode)
);
- } else {
+ } else {
+ ProxyNodePtr owner = NULL;
+ if( tnode != NULL && tnode->doc != NULL) {
+ owner = x_PmmOWNERPO(x_PmmNewNode((xmlNodePtr) tnode->doc));
+ } else {
+ owner = NULL;
+ }
+
/* need to copy the node as libxml2 will free it */
xmlNodePtr tnode_cpy = xmlCopyNode(tnode, 1);
- element = x_PmmNodeToSv(tnode_cpy, NULL);
+ element = x_PmmNodeToSv(tnode_cpy, owner);
}
XPUSHs( sv_2mortal(element) );
}