xv: Fix malloc-failure cases in the fill color key helper.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Eric Anholt 2014-04-05 09:09:17 +01:00
parent ea3f3b0786
commit 7eac142fb6

View File

@ -1094,22 +1094,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);
free(rects);
}
(*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
free(rects);
FreeScratchGC(gc);
}