From 32f6a22dd15c4b363ea5589804586c2b397e1565 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 18 Jul 2024 18:58:22 +0200 Subject: [PATCH] dri: ProcXF86DRIGetDrawableInfo() allocate temporary buffer on stack No need for going through heap, stack is also fine. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/dri/xf86dri.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index 464396f9d..20e42d8a3 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -361,7 +361,7 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) }; DrawablePtr pDrawable; int X, Y, W, H; - drm_clip_rect_t *pClipRects, *pClippedRects = NULL; + drm_clip_rect_t *pClipRects; drm_clip_rect_t *pBackClipRects; int backX, backY, rc; @@ -405,12 +405,10 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) if (rep.numBackClipRects) rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects; + drm_clip_rect_t pClippedRects[rep.numClipRects]; + if (rep.numClipRects) { /* Clip cliprects to screen dimensions (redirected windows) */ - pClippedRects = xallocarray(rep.numClipRects, sizeof(drm_clip_rect_t)); - - if (!pClippedRects) - return BadAlloc; ScreenPtr pScreen = screenInfo.screens[stuff->screen]; int i, j; @@ -441,7 +439,6 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) WriteToClient(client, sizeof(drm_clip_rect_t) * rep.numClipRects, pClippedRects); - free(pClippedRects); } if (rep.numBackClipRects) {