diff options
author | Ondřej Majerech <oxyd.oxyd@gmail.com> | 2014-08-19 15:59:45 +0200 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2014-08-20 11:43:26 +0300 |
commit | a64a475ede0a0114cff313acaa9e63a8fb180cfd (patch) | |
tree | fd1d88413c31fa3c3218a4f194d5b8a4f5ef74dd /src/vertex-clipping.c | |
parent | 06e089275d30a7803f6873cd55d1041356eb07ab (diff) |
Don't underrun the vertex array of empty polygons
This silences the following warning:
src/vertex-clipping.c:196:22: warning: array subscript is below array
bounds [-Warray-bounds]
ctx->prev.x = src->x[src->n - 1];
[Pekka Paalanen: the src->n < 2 comparison comes from the fact that a
polygon with 0 or 1 points is not a polygon. A polygon with 2 points is
still degenerate, but at least it has two edges that can be clipped.]
Signed-off-by: Ondřej Majerech <oxyd.oxyd@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'src/vertex-clipping.c')
-rw-r--r-- | src/vertex-clipping.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/vertex-clipping.c b/src/vertex-clipping.c index db527e14..2bb8c0ab 100644 --- a/src/vertex-clipping.c +++ b/src/vertex-clipping.c @@ -206,6 +206,9 @@ clip_polygon_left(struct clip_context *ctx, const struct polygon8 *src, enum path_transition trans; int i; + if (src->n < 2) + return 0; + clip_context_prepare(ctx, src, dst_x, dst_y); for (i = 0; i < src->n; i++) { trans = path_transition_left_edge(ctx, src->x[i], src->y[i]); @@ -222,6 +225,9 @@ clip_polygon_right(struct clip_context *ctx, const struct polygon8 *src, enum path_transition trans; int i; + if (src->n < 2) + return 0; + clip_context_prepare(ctx, src, dst_x, dst_y); for (i = 0; i < src->n; i++) { trans = path_transition_right_edge(ctx, src->x[i], src->y[i]); @@ -238,6 +244,9 @@ clip_polygon_top(struct clip_context *ctx, const struct polygon8 *src, enum path_transition trans; int i; + if (src->n < 2) + return 0; + clip_context_prepare(ctx, src, dst_x, dst_y); for (i = 0; i < src->n; i++) { trans = path_transition_top_edge(ctx, src->x[i], src->y[i]); @@ -254,6 +263,9 @@ clip_polygon_bottom(struct clip_context *ctx, const struct polygon8 *src, enum path_transition trans; int i; + if (src->n < 2) + return 0; + clip_context_prepare(ctx, src, dst_x, dst_y); for (i = 0; i < src->n; i++) { trans = path_transition_bottom_edge(ctx, src->x[i], src->y[i]); |