[PATCH 10/16] xv: Fix malloc-failure cases in the fill color key helper.
Alex Deucher
alexdeucher at gmail.com
Fri Jul 18 12:36:14 PDT 2014
On Fri, Jul 18, 2014 at 1:32 PM, Eric Anholt <eric at anholt.net> wrote:
> Signed-off-by: Eric Anholt <eric at anholt.net>
Does what it says on the box.
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
> ---
> Xext/xvmain.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/Xext/xvmain.c b/Xext/xvmain.c
> index a3fb711..d84708b 100644
> --- a/Xext/xvmain.c
> +++ b/Xext/xvmain.c
> @@ -1096,22 +1096,26 @@ XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
> GCPtr gc;
>
> gc = GetScratchGC(pDraw->depth, pScreen);
> + if (!gc)
> + return;
> +
> pval[0].val = key;
> pval[1].val = IncludeInferiors;
> (void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
> ValidateGC(pDraw, gc);
>
> rects = malloc(nbox * sizeof(xRectangle));
> + if (rects) {
> + for (i = 0; i < nbox; i++, pbox++) {
> + rects[i].x = pbox->x1 - pDraw->x;
> + rects[i].y = pbox->y1 - pDraw->y;
> + rects[i].width = pbox->x2 - pbox->x1;
> + rects[i].height = pbox->y2 - pbox->y1;
> + }
>
> - for (i = 0; i < nbox; i++, pbox++) {
> - rects[i].x = pbox->x1 - pDraw->x;
> - rects[i].y = pbox->y1 - pDraw->y;
> - rects[i].width = pbox->x2 - pbox->x1;
> - rects[i].height = pbox->y2 - pbox->y1;
> - }
> -
> - (*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
> + (*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
>
> - free(rects);
> + free(rects);
> + }
> FreeScratchGC(gc);
> }
> --
> 2.0.1
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
More information about the xorg-devel
mailing list