Skip Menu |

This queue is for tickets about the XML-LibXSLT CPAN distribution.

Report information
The Basics
Id: 93610
Status: new
Priority: 0/
Queue: XML-LibXSLT

Owner: Nobody in particular
Requestors: NWELLNHOF [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Subject: register_element is broken
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-14116-1394205223-92.0-0-0 [...]>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 1284
Download (untitled) / with headers
text/plain 1.2k
The implementation $stylesheet->register_element has some serious problems. Currently, the node returned fron the Perl callback is inserted into the result document using: x_PmmREFCNT_inc(PmmPROXYNODE(result)); xmlAddChild(ctxt->insert, result); 1. This leaks memory since the ref count will not be decreased. 2. The ownership of the node isn't transferred. This means that destruction of the result document can destroy the (libxml2) node even if it still has references from Perl space. Possible solutions: 1. Deep clone the node before inserting (slow). 2. Transfer ownership of the node to the new document directly using PmmFixOwner. This function has to be copied from XML::LibXML. 3. Transfer ownership indirectly by creating XML::LibXML::Node objects for the parent and child node and invoking the addChild method on the parent (complicated). IMO, the ultimate solution would be to rework the register_element interface. It would be more useful to expose the ctxt->insert node and let the Perl callback insert the nodes. This would solve the ownership problem and allow the insertion of multiple nodes which isn't possible with the current implementation. But it would break backward compatibility. OTOH, I doubt that this feature of XML::LibXLST is used at all.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to