summaryrefslogtreecommitdiffstats
path: root/src/openvg
diff options
context:
space:
mode:
authorJason Barron <jason.barron@nokia.com>2010-07-14 14:12:04 (GMT)
committerToby Tomkins <toby.tomkins@nokia.com>2010-08-02 01:18:32 (GMT)
commit79133f1dbe0150777abbd5dfb268e895b2b2ddbc (patch)
tree124648970d508f2dd52599e825a3f0bdccf91ffe /src/openvg
parent264d4c39035744c5ad073e723088b36df9cd5532 (diff)
downloadQt-79133f1dbe0150777abbd5dfb268e895b2b2ddbc.zip
Qt-79133f1dbe0150777abbd5dfb268e895b2b2ddbc.tar.gz
Qt-79133f1dbe0150777abbd5dfb268e895b2b2ddbc.tar.bz2
Avoid a crash in the OpenVG paint engine when clipping to an empty path
The convertToPainterPath() function assumes that the QVectorPath contains at least one path element when creating the QPainterPath. This is not necessarily the case here though because if QVG_SCISSOR_CLIP is defined and setClipPath() is called with an empty QPainterPath, this is then converted to an empty QVectorPath in QPaintEngineEx::clip() which then calls QVGPaintEngine::clip(). This function then goes on to convert the QVectorPath back into a QPainterPath using the aforementioned function which crashes when attempting to access the first element of the path. In case you are wondering why this seemingly redundant conversion happens at all, it happens because when QVG_SCISSOR_CLIP is defined, we attempt to convert the path to a series of rects for scissor clipping and this conversion function operates on QPainterPath instead of QVectorPath which is what this clip() function was designed to deal with. The fix is to skip over the path conversion for empty paths and go directly to an empty QRegion. Reviewed-by: Alessandro Portale (cherry picked from commit 6d29bcc28c4ee9b7583a62d23a931b9389004966)
Diffstat (limited to 'src/openvg')
-rw-r--r--src/openvg/qpaintengine_vg.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 4b22d5e..b8c60a4 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -1627,7 +1627,10 @@ void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
// Try converting the path into a QRegion that tightly follows
// the outline of the path we want to clip with.
- QRegion region(path.convertToPainterPath().toFillPolygon(QTransform()).toPolygon());
+ QRegion region;
+ if (!path.isEmpty())
+ region = QRegion(path.convertToPainterPath().toFillPolygon(QTransform()).toPolygon());
+
switch (op) {
case Qt::NoClip:
{