Record detached document of a node and use that to fix memory leak.

This commit is contained in:
rfm 2024-12-19 10:26:19 +00:00
parent 3f27cb0d23
commit 0d010003f9
3 changed files with 40 additions and 18 deletions

View file

@ -183,7 +183,12 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
self = [self initWithKind: NSXMLDocumentKind options: 0];
if (self != nil)
{
[self setRootElement: (NSXMLNode*)element];
NS_DURING
[self setRootElement: (NSXMLNode*)element];
NS_HANDLER
RELEASE(self);
[localException raise];
NS_ENDHANDLER
}
return self;
}
@ -279,6 +284,11 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
// FIXME: Should we use addChild: here?
xmlDocSetRootElement(internal->node.doc, [root _node]);
if (root->detached)
{
xmlFreeDoc(root->detached);
root->detached = 0;
}
// Do our subNode housekeeping...
[self _addSubNode: root];