st/vega: Fix a crash with empty paths.
authorChia-I Wu <olv@lunarg.com>
Wed, 24 Nov 2010 08:29:10 +0000 (16:29 +0800)
committerChia-I Wu <olv@lunarg.com>
Thu, 25 Nov 2010 05:32:03 +0000 (13:32 +0800)
src/gallium/state_trackers/vega/path.c

index 05f8b0d9979ed181c9319c8369592f1e068eb318..31c718e1c99bcc671faa0ce6a2759e886d6764d3 100644 (file)
@@ -312,7 +312,15 @@ static void polygon_array_calculate_bounds( struct polygon_array *polyarray )
    unsigned i;
 
    assert(polys);
-   assert(polys->num_elements);
+
+   if (!polys->num_elements) {
+      polyarray->min_x = 0.0f;
+      polyarray->min_y = 0.0f;
+      polyarray->max_x = 0.0f;
+      polyarray->max_y = 0.0f;
+      return;
+   }
+
    polygon_bounding_rect((((struct polygon**)polys->data)[0]), bounds);
    min_x = bounds[0];
    min_y = bounds[1];
@@ -362,7 +370,8 @@ static struct polygon_array * path_get_fill_polygons(struct path *p, struct matr
 
    sx = sy = px = py = ox = oy = 0.f;
 
-   current = polygon_create(32);
+   if (p->num_segments)
+      current = polygon_create(32);
 
    for (i = 0; i < p->num_segments; ++i) {
       VGubyte segment = ((VGubyte*)(p->segments->data))[i];