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:
parent
ea3f3b0786
commit
7eac142fb6
|
@ -1094,22 +1094,26 @@ XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
|
||||||
GCPtr gc;
|
GCPtr gc;
|
||||||
|
|
||||||
gc = GetScratchGC(pDraw->depth, pScreen);
|
gc = GetScratchGC(pDraw->depth, pScreen);
|
||||||
|
if (!gc)
|
||||||
|
return;
|
||||||
|
|
||||||
pval[0].val = key;
|
pval[0].val = key;
|
||||||
pval[1].val = IncludeInferiors;
|
pval[1].val = IncludeInferiors;
|
||||||
(void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
|
(void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
|
||||||
ValidateGC(pDraw, gc);
|
ValidateGC(pDraw, gc);
|
||||||
|
|
||||||
rects = malloc(nbox * sizeof(xRectangle));
|
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++) {
|
(*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
|
||||||
rects[i].x = pbox->x1 - pDraw->x;
|
|
||||||
rects[i].y = pbox->y1 - pDraw->y;
|
free(rects);
|
||||||
rects[i].width = pbox->x2 - pbox->x1;
|
|
||||||
rects[i].height = pbox->y2 - pbox->y1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
|
|
||||||
|
|
||||||
free(rects);
|
|
||||||
FreeScratchGC(gc);
|
FreeScratchGC(gc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue