From f8dc6361fad7682a29594bfcdfbefbe650ea88fa Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 29 Mar 2026 13:52:05 -0700 Subject: [PATCH] Xvfb: handle allocation failure in vfbInstallColormap() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported in #1817: xwayland-24.1.6/redhat-linux-build/../hw/vfb/InitOutput.c:416:13: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘ppix’ Signed-off-by: Alan Coopersmith --- hw/vfb/InitOutput.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index 0b320dfe5..5fb7f09a8 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -480,20 +480,21 @@ vfbInstallColormap(ColormapPtr pmap) prgb = xallocarray(entries, sizeof(xrgb)); defs = xallocarray(entries, sizeof(xColorItem)); - for (i = 0; i < entries; i++) - ppix[i] = i; - /* XXX truecolor */ - QueryColors(pmap, entries, ppix, prgb, serverClient); + if (ppix && prgb && defs) { + for (i = 0; i < entries; i++) + ppix[i] = i; + /* XXX truecolor */ + QueryColors(pmap, entries, ppix, prgb, serverClient); - for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */ - defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */ - defs[i].red = prgb[i].red; - defs[i].green = prgb[i].green; - defs[i].blue = prgb[i].blue; - defs[i].flags = DoRed | DoGreen | DoBlue; + for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */ + defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */ + defs[i].red = prgb[i].red; + defs[i].green = prgb[i].green; + defs[i].blue = prgb[i].blue; + defs[i].flags = DoRed | DoGreen | DoBlue; + } + (*pmap->pScreen->StoreColors) (pmap, entries, defs); } - (*pmap->pScreen->StoreColors) (pmap, entries, defs); - free(ppix); free(prgb); free(defs);