diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 5893d8448e1..dd6916f9468 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -4117,7 +4117,9 @@ void QDomAttrPrivate::setNodeValue(const QString& v) // keep the refcount balanced: appendChild() does a ref anyway. t->ref.deref(); if (first) { - delete removeChild(first); + auto removed = removeChild(first); + if (removed && !removed->ref) + delete removed; } appendChild(t); }