[PATCH v2 2/2] Don't underrun the vertex array of empty polygons

Pekka Paalanen ppaalanen at gmail.com
Wed Aug 20 02:02:49 PDT 2014


On Tue, 19 Aug 2014 15:59:45 +0200
Ondřej Majerech <oxyd.oxyd at gmail.com> wrote:

> 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];
> 
> Signed-off-by: Ondřej Majerech <oxyd.oxyd at gmail.com>
> ---
>  src/vertex-clipping.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/vertex-clipping.c b/src/vertex-clipping.c
> index db527e1..2bb8c0a 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]);

Both patches pushed. This latter one I added some more explanation to
the commit message, and then followed up with a patch to sync the
remaining copied things.


Thanks,
pq


More information about the wayland-devel mailing list