From b3ef1fbbd30d40832649e73e037964f4ff0a00ea Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 24 Feb 2025 13:51:52 +0100 Subject: [PATCH] exa: protect from allocation failure Signed-off-by: Enrico Weigelt, metux IT consult --- exa/exa_accel.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/exa/exa_accel.c b/exa/exa_accel.c index df324c53f..1d204aeae 100644 --- a/exa/exa_accel.c +++ b/exa/exa_accel.c @@ -371,7 +371,6 @@ exaHWCopyNtoN(DrawablePtr pSrcDrawable, int src_off_x, src_off_y; int dst_off_x, dst_off_y; RegionPtr srcregion = NULL, dstregion = NULL; - xRectangle *rects; Bool ret = TRUE; /* avoid doing copy operations if no boxes */ @@ -384,8 +383,7 @@ exaHWCopyNtoN(DrawablePtr pSrcDrawable, exaGetDrawableDeltas(pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y); exaGetDrawableDeltas(pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y); - rects = calloc(nbox, sizeof(xRectangle)); - + xRectangle *rects = calloc(nbox, sizeof(xRectangle)); if (rects) { int i; int ordering; @@ -614,7 +612,6 @@ exaPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, { ExaScreenPriv(pDrawable->pScreen); int i; - xRectangle *prect; /* If we can't reuse the current GC as is, don't bother accelerating the * points. @@ -624,7 +621,9 @@ exaPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, return; } - prect = calloc(npt, sizeof(xRectangle)); + xRectangle *prect = calloc(npt, sizeof(xRectangle)); + if (!prect) + return; for (i = 0; i < npt; i++) { prect[i].x = ppt[i].x; prect[i].y = ppt[i].y; @@ -649,7 +648,6 @@ exaPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr ppt) { ExaScreenPriv(pDrawable->pScreen); - xRectangle *prect; int x1, x2, y1, y2; int i; @@ -665,7 +663,9 @@ exaPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, return; } - prect = calloc(npt - 1, sizeof(xRectangle)); + xRectangle *prect = calloc(npt - 1, sizeof(xRectangle)); + if (!prect) + return; x1 = ppt[0].x; y1 = ppt[0].y; /* If we have any non-horizontal/vertical, fall back. */ @@ -718,7 +718,7 @@ static void exaPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg) { ExaScreenPriv(pDrawable->pScreen); - xRectangle *prect; +; int i; /* Don't try to do wide lines or non-solid fill style. */ @@ -736,7 +736,9 @@ exaPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg) } } - prect = calloc((unsigned int)nseg, sizeof(xRectangle)); + xRectangle *prect = calloc((unsigned int)nseg, sizeof(xRectangle)); + if (!prect) + return; for (i = 0; i < nseg; i++) { if (pSeg[i].x1 < pSeg[i].x2) { prect[i].x = pSeg[i].x1;