Xvfb: handle allocation failure in vfbInstallColormap()

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 <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2161>
This commit is contained in:
Alan Coopersmith
2026-03-29 13:52:05 -07:00
committed by Enrico Weigelt, metux IT consult
parent d9eb4d9822
commit e0facab58e

View File

@@ -480,17 +480,20 @@ vfbInstallColormap(ColormapPtr pmap)
if (!ppix || !prgb || !defs)
goto out;
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);