summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2017-11-14 14:47:08 +0100
committerEirik Aavitsland <eirik.aavitsland@qt.io>2017-11-15 07:30:00 +0000
commit18a2adad907523ea31251ff0b62e3321241a40fa (patch)
tree406882094df55cbcd0d224c9fdd110d1e5886978 /tests/auto
parentc4c9b60dc4bbe3c3837c80ea63682f3ef9403277 (diff)
downloadqtsvg-18a2adad907523ea31251ff0b62e3321241a40fa.tar.gz
Fix crash on recursive self-referral in <use> element
Referring to an ancestor in a <use> element would lead to endless recursion. Add checks to avoid recursion, and also emit a warning while parsing. Task-number: QTBUG-64425 Change-Id: I9ee1b9bfef13796cc3f387ff8579c6b13bc4ae9a Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index 6ac865a..fd1b350 100644
--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
@@ -1308,6 +1308,17 @@ void tst_QSvgRenderer::testUseElement()
" <g fill = \"red\" fill-opacity =\"0.5\">"
" <use xlink:href =\"#usedG\" />"
" </g>"
+ "</svg>",
+ // Self referral, should be ignored
+ "<svg><g id=\"0\"><use xlink:href=\"#0\" /></g></svg>",
+ "<svg width=\"200\" height=\"200\">"
+ " <rect width=\"100\" height=\"50\"/>"
+ "</svg>",
+ "<svg width=\"200\" height=\"200\">"
+ " <g id=\"0\"><use xlink:href=\"#0\" /><rect width=\"100\" height=\"50\"/></g>"
+ "</svg>",
+ "<svg width=\"200\" height=\"200\">"
+ " <g id=\"0\"><g><use xlink:href=\"#0\" /><rect width=\"100\" height=\"50\"/></g></g>"
"</svg>"
};
@@ -1334,8 +1345,10 @@ void tst_QSvgRenderer::testUseElement()
// For this reason an exact comparison will fail.
QCOMPARE(images[4], images[i]);
}
- } else if (i > 7) {
+ } else if (i > 7 && i < 10) {
QCOMPARE(images[8], images[i]);
+ } else if (i > 11) {
+ QCOMPARE(images[11], images[i]);
}
}
}