From 71f6752c62fe6198206be1d422f7fcf13b0067dc Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 4 Jan 2016 16:16:49 +0100 Subject: QQmlXmlHttpRequest: Fix a memory leak on use of XMLHttpRequest's responseXML. DocumentImpl (the root of all evil) inherits QQmlRefCount, thus, it has an initial refcount of 1. We correctly released the initial ref in the case of error, but if there is no error, we don't: we pass it over to v4 using class Node which (in Node::Node) increments the refcount again. When Node is later on collected by the GC, the document's refcount is never decreased past the initial ref, thus, not deleted. Task-number: QTBUG-50231 Change-Id: Icefe4391a785c95cb8900219be8ba71f9c53785f Reviewed-by: Lars Knoll --- src/qml/qml/qqmlxmlhttprequest.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 043113bc31..3521384d77 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -856,6 +856,7 @@ ReturnedValue Document::load(ExecutionEngine *v4, const QByteArray &data) } ScopedObject instance(scope, v4->memoryManager->allocObject(document)); + document->release(); // the GC should own the NodeImpl via Node now ScopedObject p(scope); instance->setPrototype((p = Document::prototype(v4))); return instance.asReturnedValue(); -- cgit v1.2.3