From 14058a13323855bc33c8af888b7b5095cdfbe71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 25 Apr 2018 00:15:41 -0500 Subject: [PATCH] panoramiX: grow depths visuals dynamically We need to ensure we've enough elements where writing the Visual depths or we could end up in a memory error. https://bugs.freedesktop.org/show_bug.cgi?id=106230 --- Xext/panoramiX.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index 844ea49ce..59947d61d 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -750,12 +750,8 @@ PanoramiXMaybeAddDepth(DepthPtr pDepth) PanoramiXDepths = reallocarray(PanoramiXDepths, PanoramiXNumDepths, sizeof(DepthRec)); PanoramiXDepths[j].depth = pDepth->depth; + PanoramiXDepths[j].vids = NULL; PanoramiXDepths[j].numVids = 0; - /* XXX suboptimal, should grow these dynamically */ - if (pDepth->numVids) - PanoramiXDepths[j].vids = xallocarray(pDepth->numVids, sizeof(VisualID)); - else - PanoramiXDepths[j].vids = NULL; } static void @@ -796,6 +792,9 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual) for (k = 0; k < PanoramiXNumDepths; k++) { if (PanoramiXDepths[k].depth == pVisual->nplanes) { + PanoramiXDepths[k].vids = reallocarray(PanoramiXDepths[k].vids, + PanoramiXDepths[k].numVids + 1, + sizeof(VisualID)); PanoramiXDepths[k].vids[PanoramiXDepths[k].numVids] = pVisual->vid; PanoramiXDepths[k].numVids++; break; -- 2.17.0