From df938a515bd59138421b6ab4419966805d027b52 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 17 Dec 2007 21:39:25 +0000 Subject: [PATCH] [cairo-path-bounds] Check for the empty path. Avoid returning uninitialized variables if we're asked to find the bounds of an empty path - in which case we just return a rectangle of zero width and height similar to the empty clip region. --- src/cairo-path-bounds.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c index 5b60cf1c3..49b4ab983 100644 --- a/src/cairo-path-bounds.c +++ b/src/cairo-path-bounds.c @@ -165,18 +165,16 @@ _cairo_path_fixed_bounds (cairo_path_fixed_t *path, _cairo_path_bounder_curve_to, _cairo_path_bounder_close_path, &bounder); - if (status) { - *x1 = *y1 = *x2 = *y2 = 0.0; - _cairo_path_bounder_fini (&bounder); - return status; + if (status || ! bounder.has_point) { + *x1 = *y1 = *x2 = *y2 = 0.; + } else { + *x1 = _cairo_fixed_to_double (bounder.min_x); + *y1 = _cairo_fixed_to_double (bounder.min_y); + *x2 = _cairo_fixed_to_double (bounder.max_x); + *y2 = _cairo_fixed_to_double (bounder.max_y); } - *x1 = _cairo_fixed_to_double (bounder.min_x); - *y1 = _cairo_fixed_to_double (bounder.min_y); - *x2 = _cairo_fixed_to_double (bounder.max_x); - *y2 = _cairo_fixed_to_double (bounder.max_y); - _cairo_path_bounder_fini (&bounder); - return CAIRO_STATUS_SUCCESS; + return status; }