summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@qt.io>2020-07-15 20:32:46 +0200
committerRobert Loehning <robert.loehning@qt.io>2020-07-30 22:23:32 +0200
commit3f11586d79566c9ceb311c6c4a1ea12078deed5d (patch)
treea6dc8f549dfb97309f7b86e8ff3714a3362793b9 /src
parent8368111c76471a7415c29ba293848003fca2a4af (diff)
downloadqtsvg-3f11586d79566c9ceb311c6c4a1ea12078deed5d.tar.gz
Avoid endless recursion in SvgStructureNode::bounds
Fixes: oss-fuzz-24028 Pick-to: 5.12 5.15 Change-Id: I2ddfcd494747f2857d56ce54bc9c4ee3f986ac3e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/svg/qsvgstructure.cpp9
-rw-r--r--src/svg/qsvgstructure_p.h1
2 files changed, 8 insertions, 2 deletions
diff --git a/src/svg/qsvgstructure.cpp b/src/svg/qsvgstructure.cpp
index 398cd5d..b89608b 100644
--- a/src/svg/qsvgstructure.cpp
+++ b/src/svg/qsvgstructure.cpp
@@ -47,6 +47,8 @@
#include "qlocale.h"
#include "qdebug.h"
+#include <qscopedvaluerollback.h>
+
QT_BEGIN_NAMESPACE
QSvgG::QSvgG(QSvgNode *parent)
@@ -356,8 +358,11 @@ void QSvgSwitch::init()
QRectF QSvgStructureNode::bounds(QPainter *p, QSvgExtraStates &states) const
{
QRectF bounds;
- for (QSvgNode *node : qAsConst(m_renderers))
- bounds |= node->transformedBounds(p, states);
+ if (!m_recursing) {
+ QScopedValueRollback<bool> guard(m_recursing, true);
+ for (QSvgNode *node : qAsConst(m_renderers))
+ bounds |= node->transformedBounds(p, states);
+ }
return bounds;
}
diff --git a/src/svg/qsvgstructure_p.h b/src/svg/qsvgstructure_p.h
index b055364..6b69364 100644
--- a/src/svg/qsvgstructure_p.h
+++ b/src/svg/qsvgstructure_p.h
@@ -78,6 +78,7 @@ protected:
QList<QSvgNode*> m_renderers;
QHash<QString, QSvgNode*> m_scope;
QList<QSvgStructureNode*> m_linkedScopes;
+ mutable bool m_recursing = false;
};
class Q_SVG_PRIVATE_EXPORT QSvgG : public QSvgStructureNode