From c8dbff8b5ae8e4b5ef8a46a5e3b513a5f6f4a205 Mon Sep 17 00:00:00 2001
From: Gunnar Sletta <gunnar@trolltech.com>
Date: Fri, 24 Jul 2009 09:35:41 +0200
Subject: Fixed crash when vectorpath was polygonal only in raster::stroke()

Polygonal vector paths may have types==null, in which case this
would have crashed.

Reviewed-by: Eskil
---
 src/gui/painting/qpaintengine_raster.cpp | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 5176444..069c350 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -1687,17 +1687,24 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
         int count = path.elementCount();
         QPointF *points = (QPointF *) path.points();
         const QPainterPath::ElementType *types = path.elements();
-        int first = 0;
-        int last;
-        while (first < count) {
-            while (first < count && types[first] != QPainterPath::MoveToElement) ++first;
-            last = first + 1;
-            while (last < count && types[last] == QPainterPath::LineToElement) ++last;
-            strokePolygonCosmetic(points + first, last - first,
-                                  path.hasImplicitClose() && last == count // only close last one..
+        if (types) {
+            int first = 0;
+            int last;
+            while (first < count) {
+                while (first < count && types[first] != QPainterPath::MoveToElement) ++first;
+                last = first + 1;
+                while (last < count && types[last] == QPainterPath::LineToElement) ++last;
+                strokePolygonCosmetic(points + first, last - first,
+                                      path.hasImplicitClose() && last == count // only close last one..
+                                      ? WindingMode
+                                      : PolylineMode);
+                first = last;
+            }
+        } else {
+            strokePolygonCosmetic(points, count,
+                                  path.hasImplicitClose()
                                   ? WindingMode
                                   : PolylineMode);
-            first = last;
         }
 
     } else if (s->flags.non_complex_pen && path.shape() == QVectorPath::LinesHint) {
-- 
cgit v0.12