[PATCH 10/16] xv: Fix malloc-failure cases in the fill color key helper.
Eric Anholt
eric at anholt.net
Fri Jul 18 10:32:27 PDT 2014
Signed-off-by: Eric Anholt <eric at anholt.net>
---
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
More information about the xorg-devel
mailing list