summaryrefslogtreecommitdiff
path: root/src/svg
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2020-03-02 09:56:44 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2020-03-02 09:56:44 +0100
commit4211887afdc52dd423482b277a2ad36c3b0ea76a (patch)
tree75c875864b6a01785f2be5c52f30b2ea841dd889 /src/svg
parent0823c68b6e34076afad31a12d3fb438b123879cc (diff)
parentae1e354bec49fa7d57074ec1636b1f0c0f7c5019 (diff)
downloadqtsvg-4211887afdc52dd423482b277a2ad36c3b0ea76a.tar.gz
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: examples/svg/svg.pro Change-Id: I186ffe58bd314b505060b2ef5b090503d5a59618
Diffstat (limited to 'src/svg')
-rw-r--r--src/svg/qsvggraphics.cpp17
-rw-r--r--src/svg/qsvgstyle_p.h2
2 files changed, 18 insertions, 1 deletions
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp
index bcd2452..20a03ff 100644
--- a/src/svg/qsvggraphics.cpp
+++ b/src/svg/qsvggraphics.cpp
@@ -43,6 +43,7 @@
#include <qabstracttextdocumentlayout.h>
#include <qdebug.h>
+#include <qloggingcategory.h>
#include <qpainter.h>
#include <qscopedvaluerollback.h>
#include <qtextcursor.h>
@@ -53,6 +54,8 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcSvgDraw, "qt.svg.draw")
+
#define QT_SVG_DRAW_SHAPE(command) \
qreal oldOpacity = p->opacity(); \
QBrush oldBrush = p->brush(); \
@@ -469,15 +472,27 @@ void QSvgUse::draw(QPainter *p, QSvgExtraStates &states)
if (Q_UNLIKELY(!m_link || isDescendantOf(m_link) || m_recursing))
return;
+ Q_ASSERT(states.nestedUseCount == 0 || states.nestedUseLevel > 0);
+ if (states.nestedUseLevel > 3 && states.nestedUseCount > (256 + states.nestedUseLevel * 2)) {
+ qCDebug(lcSvgDraw, "Too many nested use nodes at #%s!", qPrintable(m_linkId));
+ return;
+ }
+
applyStyle(p, states);
if (!m_start.isNull()) {
p->translate(m_start);
}
+ if (states.nestedUseLevel > 0)
+ ++states.nestedUseCount;
{
- QScopedValueRollback<bool> guard(m_recursing, true);
+ QScopedValueRollback<int> useLevelGuard(states.nestedUseLevel, states.nestedUseLevel + 1);
+ QScopedValueRollback<bool> recursingGuard(m_recursing, true);
m_link->draw(p, states);
}
+ if (states.nestedUseLevel == 0)
+ states.nestedUseCount = 0;
+
if (!m_start.isNull()) {
p->translate(-m_start);
}
diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h
index 9dd4f53..5e0b7cc 100644
--- a/src/svg/qsvgstyle_p.h
+++ b/src/svg/qsvgstyle_p.h
@@ -145,6 +145,8 @@ struct Q_SVG_PRIVATE_EXPORT QSvgExtraStates
int fontWeight;
Qt::FillRule fillRule;
qreal strokeDashOffset;
+ int nestedUseLevel = 0;
+ int nestedUseCount = 0;
bool vectorEffect; // true if pen is cosmetic
};