summaryrefslogtreecommitdiff
path: root/src/svg/qsvgstyle.cpp
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2019-04-01 14:17:11 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2019-04-02 09:11:40 +0000
commit15f74a0f8a41759e1216d52d53852c05c9299107 (patch)
treeb25b1cb20c25a39d14e8457042f355a85dcaf009 /src/svg/qsvgstyle.cpp
parentd477ec8f40b28caf3a216d9e8550d8871d5131fb (diff)
downloadqtsvg-15f74a0f8a41759e1216d52d53852c05c9299107.tar.gz
Fix crash for recursive gradient references
A reference loop with at least three elements would lead to endless recursion. Fixes: QTBUG-74189 Change-Id: Ie3c1b32da0e98e9218dc387dd3210666018a92e1 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/svg/qsvgstyle.cpp')
-rw-r--r--src/svg/qsvgstyle.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp
index 5448797..b934f94 100644
--- a/src/svg/qsvgstyle.cpp
+++ b/src/svg/qsvgstyle.cpp
@@ -942,13 +942,20 @@ void QSvgGradientStyle::setStopLink(const QString &link, QSvgTinyDocument *doc)
void QSvgGradientStyle::resolveStops()
{
+ QStringList visited;
+ resolveStops_helper(&visited);
+}
+
+void QSvgGradientStyle::resolveStops_helper(QStringList *visited)
+{
if (!m_link.isEmpty() && m_doc) {
QSvgStyleProperty *prop = m_doc->styleProperty(m_link);
- if (prop && prop != this) {
+ if (prop && !visited->contains(m_link)) {
+ visited->append(m_link);
if (prop->type() == QSvgStyleProperty::GRADIENT) {
QSvgGradientStyle *st =
static_cast<QSvgGradientStyle*>(prop);
- st->resolveStops();
+ st->resolveStops_helper(visited);
m_gradient->setStops(st->qgradient()->stops());
m_gradientStopsSet = st->gradientStopsSet();
}