avoid divide-by-zero resulting from push_group
authorvladimir@pobox.com
Thu, 02 Aug 2007 05:48:30 -0700
changeset 4157 f446c5648201251cb9c9a3dee0f9299d48521538
parent 4156 42b2b483bed7b6f11c69bcc1d6721b401b06811b
child 4158 71bf16e942c3444313b5e23e35314e6b455efdf4
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9a7pre
avoid divide-by-zero resulting from push_group
gfx/cairo/cairo/src/cairo.c
--- a/gfx/cairo/cairo/src/cairo.c
+++ b/gfx/cairo/cairo/src/cairo.c
@@ -475,33 +475,40 @@ slim_hidden_def(cairo_push_group);
  * Since: 1.2
  */
 void
 cairo_push_group_with_content (cairo_t *cr, cairo_content_t content)
 {
     cairo_status_t status;
     cairo_rectangle_int_t extents;
     cairo_surface_t *parent_surface, *group_surface = NULL;
+    int width;
+    int height;
 
     if (cr->status)
 	return;
 
     parent_surface = _cairo_gstate_get_target (cr->gstate);
     /* Get the extents that we'll use in creating our new group surface */
     status = _cairo_surface_get_extents (parent_surface, &extents);
     if (status)
 	goto bail;
     status = _cairo_clip_intersect_to_rectangle (_cairo_gstate_get_clip (cr->gstate), &extents);
     if (status)
 	goto bail;
 
+    width = extents.width;
+    height = extents.height;
+
+    if (width == 0 || height == 0)
+	width = height = 1;
+
     group_surface = cairo_surface_create_similar (_cairo_gstate_get_target (cr->gstate),
 						  content,
-						  extents.width,
-						  extents.height);
+						  width, height);
     status = cairo_surface_status (group_surface);
     if (status)
 	goto bail;
 
     /* Set device offsets on the new surface so that logically it appears at
      * the same location on the parent surface -- when we pop_group this,
      * the source pattern will get fixed up for the appropriate target surface
      * device offsets, so we want to set our own surface offsets from /that/,