[cairo-commit] src/cairo-gstate.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Oct 22 09:17:18 PDT 2007


 src/cairo-gstate.c |    5 +++++
 1 file changed, 5 insertions(+)

New commits:
commit e3248a21841cfcbc285d76e2299485f9822857f1
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 22 09:34:55 2007 +0100

    [cairo-matrix] Check user input for invalid numbers.
    
    Supplement the guards for scale==0 with checks that the user does not
    attempt to translate or scale by invalid numbers.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 3e92c54..499e9aa 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -613,6 +613,9 @@ _cairo_gstate_translate (cairo_gstate_t *gstate, double tx, double ty)
 {
     cairo_matrix_t tmp;
 
+    if (! (tx * tx >= 0.) || ! (ty * ty >= 0.))
+	return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+
     _cairo_gstate_unset_scaled_font (gstate);
 
     cairo_matrix_init_translate (&tmp, tx, ty);
@@ -631,6 +634,8 @@ _cairo_gstate_scale (cairo_gstate_t *gstate, double sx, double sy)
 
     if (sx == 0 || sy == 0)
 	return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+    if (! (sx * sx > 0.) || ! (sy * sy > 0.))
+	return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
 
     _cairo_gstate_unset_scaled_font (gstate);
 


More information about the cairo-commit mailing list