summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-01-13 11:02:55 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-01-13 11:02:55 +0000
commit2f600affaa9ac3537013c69643878731a2f4389e (patch)
tree40316dc9ec4092f69b4974d2cd9b5f141020ac77 /src
parent3fed79d1c24f07618243bb197b44a9fd106aebbc (diff)
[cairo-gstate] Add isfinite guards to the transformation ops.
If we have isfinite() available use it to check that the user supplied arguments are valid.
Diffstat (limited to 'src')
-rw-r--r--src/cairo-gstate.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 5c626cdc..1f040d0a 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -35,11 +35,17 @@
* Carl D. Worth <cworth@cworth.org>
*/
+#define _GNU_SOURCE
+
#include "cairoint.h"
#include "cairo-clip-private.h"
#include "cairo-gstate-private.h"
+#if _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
+#define HAVE_ISFINITE 1
+#endif
+
static cairo_status_t
_cairo_gstate_init_copy (cairo_gstate_t *gstate, cairo_gstate_t *other);
@@ -623,8 +629,13 @@ _cairo_gstate_translate (cairo_gstate_t *gstate, double tx, double ty)
{
cairo_matrix_t tmp;
+#if HAVE_ISFINITE
+ if (! isfinite (tx) || ! isfinite (ty))
+ return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+#else
if (! (tx * tx >= 0.) || ! (ty * ty >= 0.)) /* check for NaNs */
return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+#endif
_cairo_gstate_unset_scaled_font (gstate);
@@ -644,8 +655,13 @@ _cairo_gstate_scale (cairo_gstate_t *gstate, double sx, double sy)
if (sx * sy == 0.) /* either sx or sy is 0, or det == 0 due to underflow */
return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+#if HAVE_ISFINITE
+ if (! isfinite (sx) || ! isfinite (sy))
+ return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+#else
if (! (sx * sx > 0.) || ! (sy * sy > 0.)) /* check for NaNs */
return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+#endif
_cairo_gstate_unset_scaled_font (gstate);
@@ -666,8 +682,13 @@ _cairo_gstate_rotate (cairo_gstate_t *gstate, double angle)
if (angle == 0.)
return CAIRO_STATUS_SUCCESS;
+#if HAVE_ISFINITE
+ if (! isfinite (angle))
+ return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+#else
if (! (angle * angle >= 0.)) /* check for NaNs */
return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+#endif
_cairo_gstate_unset_scaled_font (gstate);