diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-15 11:00:49 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-15 11:49:08 +0000 |
commit | b159b766eb7974419c2f16a01a8d15221c352dbf (patch) | |
tree | 597a7fc46f63b9861d30ea50648029908a284f60 | |
parent | 925b18d0cbb444d5a05fbc5689463f2b0ec11927 (diff) |
Fix SVG shape path parsing to not crash when read-only strings
The SVG parser code copied from qsvg.cpp used to operate on QStringRef
which had no zero termination guarantee. However it did operate on
mutable underlying data, so a temporary insertion of a termination
during path parsing was "fine".
The copied parser here operates on a QString and with upcoming changes
in QtQml, those strings may now be located in read-only memory. However
QStrings are null terminated (unless carelessly constructed), so we
don't need the hack here.
Change-Id: If26b4a5168e4abc2e14bb37dcd631672f2a65e4b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r-- | src/quick/util/qquicksvgparser.cpp | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/src/quick/util/qquicksvgparser.cpp b/src/quick/util/qquicksvgparser.cpp index 2bf9c121d3..0687913565 100644 --- a/src/quick/util/qquicksvgparser.cpp +++ b/src/quick/util/qquicksvgparser.cpp @@ -280,11 +280,8 @@ bool QQuickSvgParser::parsePathDataFast(const QString &dataStr, QPainterPath &pa ++str; QChar pathElem = *str; ++str; - QChar endc = *end; - *const_cast<QChar *>(end) = 0; // parseNumbersArray requires 0-termination that QStringRef cannot guarantee QVarLengthArray<qreal, 8> arg; parseNumbersArray(str, arg); - *const_cast<QChar *>(end) = endc; if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z')) arg.append(0);//dummy const qreal *num = arg.constData(); |