QDomDocument::toByteArray() crashed in case of high XML nesting level

The issue the combination of:
- 300+ XML nesting level
- Small stack size, by default on Windows (1 MB)
- Unexpected and unexplained large stack frames with MSVC (3.5 kB)

The described factors combination leads to the stack overflow on
Windows + MSVC.

To fix the problem, I got rid of the recursive call from
QDomElementPrivate::save() and removed QDomNodePrivate::save()
implementation.

Instead of those I added the method that iterates through the tree not
using recursion.

[ChangeLog][QtXml] QDomDocument::toByteArray() now iterates the
nodes of the document instead of recursing into subnodes. This avoids
a stack-overflow crash that used to arise with deeply-nested document
structures.

Fixes: QTBUG-131151
Change-Id: Ib74aaef1422716f2aafcb89dfc8c05ef334e2a54
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 387633a6069a5e0e9b976971691b1b82725b6132)
This commit is contained in:
Tatiana Borisova 2024-11-26 21:18:40 +01:00
parent 03565b3956
commit 948599e7b7
4 changed files with 471 additions and 19 deletions

View File

@ -1349,16 +1349,40 @@ void QDomNodePrivate::normalize()
qNormalizeNode(this); qNormalizeNode(this);
} }
/*! \internal void QDomNodePrivate::saveSubTree(const QDomNodePrivate *n, QTextStream &s,
\a depth is used for indentation, it seems. int depth, int indent) const
*/
void QDomNodePrivate::save(QTextStream& s, int depth, int indent) const
{ {
const QDomNodePrivate* n = first; if (!n)
while (n) { return;
n->save(s, depth, indent);
n = n->next; const QDomNodePrivate *root = n->first;
n->save(s, depth, indent);
if (root) {
const int branchDepth = depth + 1;
int layerDepth = 0;
while (root) {
root->save(s, layerDepth + branchDepth, indent);
// A flattened (non-recursive) depth-first walk through the node tree.
if (root->first) {
layerDepth ++;
root = root->first;
continue;
}
root->afterSave(s, layerDepth + branchDepth, indent);
const QDomNodePrivate *prev = root;
root = root->next;
// Close QDomElementPrivate groups
while (!root && prev && (layerDepth > 0)) {
root = prev->parent();
layerDepth --;
root->afterSave(s, layerDepth + branchDepth, indent);
prev = root;
root = root->next;
}
}
Q_ASSERT(layerDepth == 0);
} }
n->afterSave(s, depth, indent);
} }
void QDomNodePrivate::setLocation(int lineNumber, int columnNumber) void QDomNodePrivate::setLocation(int lineNumber, int columnNumber)
@ -2146,7 +2170,7 @@ void QDomNode::save(QTextStream& stream, int indent, EncodingPolicy encodingPoli
if (isDocument()) if (isDocument())
static_cast<const QDomDocumentPrivate *>(impl)->saveDocument(stream, indent, encodingPolicy); static_cast<const QDomDocumentPrivate *>(impl)->saveDocument(stream, indent, encodingPolicy);
else else
IMPL->save(stream, 1, indent); IMPL->saveSubTree(IMPL, stream, 1, indent);
} }
/*! /*!
@ -3064,11 +3088,11 @@ void QDomDocumentTypePrivate::save(QTextStream& s, int, int indent) const
auto it2 = notations->map.constBegin(); auto it2 = notations->map.constBegin();
for (; it2 != notations->map.constEnd(); ++it2) for (; it2 != notations->map.constEnd(); ++it2)
it2.value()->save(s, 0, indent); it2.value()->saveSubTree(it2.value(), s, 0, indent);
auto it = entities->map.constBegin(); auto it = entities->map.constBegin();
for (; it != entities->map.constEnd(); ++it) for (; it != entities->map.constEnd(); ++it)
it.value()->save(s, 0, indent); it.value()->saveSubTree(it.value(), s, 0, indent);
s << ']'; s << ']';
} }
@ -4121,13 +4145,25 @@ void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const
if (indent != -1) if (indent != -1)
s << Qt::endl; s << Qt::endl;
} }
QDomNodePrivate::save(s, depth + 1, indent); if (!last->isText())
s << QString(indent < 1 ? 0 : depth * indent, u' ');
s << "</" << qName << '>';
} else { } else {
s << "/>"; s << "/>";
} }
}
void QDomElementPrivate::afterSave(QTextStream &s, int depth, int indent) const
{
if (last) {
QString qName(name);
if (!prefix.isEmpty())
qName = prefix + u':' + name;
if (!last->isText())
s << QString(indent < 1 ? 0 : depth * indent, u' ');
s << "</" << qName << '>';
}
if (!(next && next->isText())) { if (!(next && next->isText())) {
/* -1 disables new lines. */ /* -1 disables new lines. */
if (indent != -1) if (indent != -1)
@ -5908,7 +5944,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod
type->save(s, 0, indent); type->save(s, 0, indent);
doc = true; doc = true;
} }
n->save(s, 0, indent); n->saveSubTree(n, s, 0, indent);
n = n->next; n = n->next;
} }
} }
@ -5935,8 +5971,8 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod
} }
// Now we serialize all the nodes after the faked XML declaration(the PI). // Now we serialize all the nodes after the faked XML declaration(the PI).
while(startNode) { while (startNode) {
startNode->save(s, 0, indent); startNode->saveSubTree(startNode, s, 0, indent);
startNode = startNode->next; startNode = startNode->next;
} }
} }

View File

@ -109,7 +109,9 @@ public:
virtual QDomNode::NodeType nodeType() const { return QDomNode::BaseNode; } virtual QDomNode::NodeType nodeType() const { return QDomNode::BaseNode; }
virtual void save(QTextStream &, int, int) const; void saveSubTree(const QDomNodePrivate *n, QTextStream &s, int depth, int indent) const;
virtual void save(QTextStream &, int, int) const {}
virtual void afterSave(QTextStream &, int, int) const {}
void setLocation(int lineNumber, int columnNumber); void setLocation(int lineNumber, int columnNumber);
@ -328,6 +330,7 @@ public:
QDomNode::NodeType nodeType() const override { return QDomNode::ElementNode; } QDomNode::NodeType nodeType() const override { return QDomNode::ElementNode; }
QDomNodePrivate *cloneNode(bool deep = true) override; QDomNodePrivate *cloneNode(bool deep = true) override;
virtual void save(QTextStream &s, int, int) const override; virtual void save(QTextStream &s, int, int) const override;
virtual void afterSave(QTextStream &s, int, int) const override;
// Variables // Variables
QDomNamedNodeMapPrivate *m_attr; QDomNamedNodeMapPrivate *m_attr;

View File

@ -0,0 +1,396 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve" viewBox="0 0 300 300">
<g fill="#CB8252">
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<g><rect x="25" y="220" width="50" height="50" />
<!-- 376 -->
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g></g>
</svg>

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -114,6 +114,7 @@ private slots:
void QTBUG49113_dontCrashWithNegativeIndex() const; void QTBUG49113_dontCrashWithNegativeIndex() const;
void standalone(); void standalone();
void splitTextLeakMemory() const; void splitTextLeakMemory() const;
void noCrashOnDeepNesting() const;
void cleanupTestCase() const; void cleanupTestCase() const;
@ -2337,5 +2338,21 @@ void tst_QDom::splitTextLeakMemory() const
QCOMPARE(end.impl->ref.loadRelaxed(), 2); QCOMPARE(end.impl->ref.loadRelaxed(), 2);
} }
// The fix of QTBUG-131151 crash
void tst_QDom::noCrashOnDeepNesting() const
{
const QString prefix = QFINDTESTDATA("testdata/");
if (prefix.isEmpty())
QFAIL("Cannot find testdata directory!");
QFile file(prefix + "/deeply-nested.svg");
QVERIFY(file.open(QIODevice::ReadOnly));
QDomDocument doc;
doc.setContent(&file);
QByteArray array = doc.toByteArray();
QVERIFY(array.size());
file.close();
}
QTEST_MAIN(tst_QDom) QTEST_MAIN(tst_QDom)
#include "tst_qdom.moc" #include "tst_qdom.moc"