[PATCH 0/1] MR10335: msxml3: Don't add cloned doc to orphan list.
Adding the document node to its own orphan list creates a circular reference. Also, create_domdoc bumps the refcount twice. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10335
From: Daniel Lehman <dlehman25@gmail.com> Adding the document node to its own orphan list creates a circular reference. Also, create_domdoc bumps the refcount twice. --- dlls/msxml3/domdoc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index 1e7398f8d70..505ac496eed 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -1284,16 +1284,10 @@ static HRESULT WINAPI domdoc_cloneNode( return E_FAIL; clone->doc->_private = create_priv(); - xmldoc_add_orphan(clone->doc, clone); - xmldoc_add_ref(clone->doc); - priv_from_xmlDocPtr(clone->doc)->properties = copy_properties(This->properties); + xmldoc_release(clone->doc); if (!(*outNode = (IXMLDOMNode*)create_domdoc(clone))) - { - xmldoc_release(clone->doc); return E_FAIL; - } - return S_OK; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10335
@nsivov this might also be covered by your rework of DOM handling but wanted to highlight this because it led to a sizable memory leak. the xmlDoc has 3 references on the return from cloneNode. Release() reaches zero on msxml3's node but not the xmlDoc node. i can push a branch with a test if you want -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10335#note_132271
On Thu Mar 19 14:00:16 2026 +0000, Daniel Lehman wrote:
@nsivov this might also be covered by your rework of DOM handling but wanted to highlight this because it led to a sizable memory leak. the xmlDoc has 3 references on the return from cloneNode. Release() reaches zero on msxml3's node but not the xmlDoc node. i can push a branch with a test if you want Yes, the way I did it now is to tracked owned nodes in the document node, while document node itself is not owned.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10335#note_132805
This merge request was approved by Nikolay Sivov. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10335
participants (3)
-
Daniel Lehman -
Daniel Lehman (@dlehman25) -
Nikolay Sivov (@nsivov)