From 4b70d1eebba2ddfd692dea6cb5b5457f7c923edf Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 21 Apr 2015 07:54:28 +0100 Subject: [PATCH] prelim-stroke-validate --- src/cairo-path-stroke-boxes.c | 4 ++++ src/cairo-path-stroke-polygon.c | 4 ++++ src/cairo-path-stroke-traps.c | 4 ++++ src/cairo-path-stroke-tristrip.c | 4 ++++ src/cairo-path-stroke.c | 4 ++++ src/cairo-stroke-style.c | 13 +++++++++++++ src/cairoint.h | 4 ++++ 7 files changed, 37 insertions(+) diff --git a/src/cairo-path-stroke-boxes.c b/src/cairo-path-stroke-boxes.c index 7f25bf7..6511d23 100644 --- a/src/cairo-path-stroke-boxes.c +++ b/src/cairo-path-stroke-boxes.c @@ -619,6 +619,10 @@ _cairo_path_fixed_stroke_rectilinear_to_boxes (const cairo_path_fixed_t *path, assert (_cairo_path_fixed_stroke_is_rectilinear (path)); + status = _cairo_stroke_style_fixed_validate (stroke_style, ctm); + if (unlikely (status)) + return status; + if (! _cairo_rectilinear_stroker_init (&rectilinear_stroker, stroke_style, ctm, antialias, boxes)) diff --git a/src/cairo-path-stroke-polygon.c b/src/cairo-path-stroke-polygon.c index e5082bb..f9f7064 100644 --- a/src/cairo-path-stroke-polygon.c +++ b/src/cairo-path-stroke-polygon.c @@ -1252,6 +1252,10 @@ _cairo_path_fixed_stroke_to_polygon (const cairo_path_fixed_t *path, struct stroker stroker; cairo_status_t status; + status = _cairo_stroke_style_fixed_validate (style, ctm); + if (unlikely (status)) + return status; + if (style->num_dashes) { return _cairo_path_fixed_stroke_dashed_to_polygon (path, style, diff --git a/src/cairo-path-stroke-traps.c b/src/cairo-path-stroke-traps.c index da54e5a..e183d10 100644 --- a/src/cairo-path-stroke-traps.c +++ b/src/cairo-path-stroke-traps.c @@ -92,6 +92,10 @@ stroker_init (struct stroker *stroker, { cairo_status_t status; + status = _cairo_stroke_style_fixed_validate (style, ctm); + if (unlikely (status)) + return status; + stroker->style = style; stroker->ctm = ctm; stroker->ctm_inverse = NULL; diff --git a/src/cairo-path-stroke-tristrip.c b/src/cairo-path-stroke-tristrip.c index 6ce4131..60b662f 100644 --- a/src/cairo-path-stroke-tristrip.c +++ b/src/cairo-path-stroke-tristrip.c @@ -1044,6 +1044,10 @@ _cairo_path_fixed_stroke_to_tristrip (const cairo_path_fixed_t *path, if (style->num_dashes) return CAIRO_INT_STATUS_UNSUPPORTED; + status = _cairo_stroke_style_fixed_validate (style, ctm); + if (unlikely (status)) + return status; + stroker.style = *style; stroker.ctm = ctm; stroker.ctm_inverse = ctm_inverse; diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c index 4d4ede8..a4e17fd 100644 --- a/src/cairo-path-stroke.c +++ b/src/cairo-path-stroke.c @@ -132,6 +132,10 @@ _cairo_stroker_init (cairo_stroker_t *stroker, { cairo_status_t status; + status = _cairo_stroke_style_fixed_validate (stroke_style, ctm); + if (unlikely (status)) + return status; + stroker->style = *stroke_style; stroker->ctm = ctm; stroker->ctm_inverse = ctm_inverse; diff --git a/src/cairo-stroke-style.c b/src/cairo-stroke-style.c index 51c9414..48e98e1 100644 --- a/src/cairo-stroke-style.c +++ b/src/cairo-stroke-style.c @@ -83,6 +83,19 @@ _cairo_stroke_style_init_copy (cairo_stroke_style_t *style, return CAIRO_STATUS_SUCCESS; } +cairo_status_t +_cairo_stroke_style_fixed_validate (const cairo_stroke_style_t *stroke_style, + const cairo_matrix_t *ctm) +{ + double det; + + det = _cairo_matrix_compute_determinant (ctm); + if (det * stroke_style->line_width > 1 << (CAIRO_FIXED_BITS - 1)) + return _cairo_error (CAIRO_STATUS_INVALID_SIZE); + + return CAIRO_STATUS_SUCCESS; +} + void _cairo_stroke_style_fini (cairo_stroke_style_t *style) { diff --git a/src/cairoint.h b/src/cairoint.h index 5bca003..2602b02 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -1264,6 +1264,10 @@ cairo_private cairo_status_t _cairo_stroke_style_init_copy (cairo_stroke_style_t *style, const cairo_stroke_style_t *other); +cairo_private cairo_status_t +_cairo_stroke_style_fixed_validate (const cairo_stroke_style_t *stroke_style, + const cairo_matrix_t *ctm); + cairo_private void _cairo_stroke_style_fini (cairo_stroke_style_t *style); -- 2.1.4