From b32cd8c759bfcd4066df12ad07c93e84f5c54ca2 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 24 Feb 2025 13:57:27 +0100 Subject: [PATCH] xvfb: protect from memory allocation failure Signed-off-by: Enrico Weigelt, metux IT consult --- hw/vfb/InitOutput.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index a2d48b630..cd3b2e0a8 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -484,6 +484,8 @@ vfbInstallColormap(ColormapPtr pmap) ppix = calloc(entries, sizeof(Pixel)); prgb = calloc(entries, sizeof(xrgb)); defs = calloc(entries, sizeof(xColorItem)); + if (!ppix || !prgb || !defs) + goto out; for (i = 0; i < entries; i++) ppix[i] = i; @@ -499,6 +501,7 @@ vfbInstallColormap(ColormapPtr pmap) } (*pmap->pScreen->StoreColors) (pmap, entries, defs); +out: free(ppix); free(prgb); free(defs);