diff options
author | Eric Anholt <eric@anholt.net> | 2014-04-05 09:09:17 +0100 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2014-08-06 20:12:20 -0700 |
commit | 7eac142fb6e8abb011ce59feda3c2d7b04f2b225 (patch) | |
tree | 54e8e33fcbb69bc0e94efb4d8548cfa412596a90 /Xext | |
parent | ea3f3b0786d58b2ba6a9bbf0a32e734670f54b73 (diff) |
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>
Diffstat (limited to 'Xext')
-rw-r--r-- | Xext/xvmain.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Xext/xvmain.c b/Xext/xvmain.c index d932dfdfc..389be0d56 100644 --- a/Xext/xvmain.c +++ b/Xext/xvmain.c @@ -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); + (*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects); - free(rects); + free(rects); + } FreeScratchGC(gc); } |