From 654c7ce1df215143e4fb71dcfe160950471c6490 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 ffe9378d0..019d3efd2 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -486,6 +486,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; @@ -501,6 +503,7 @@ vfbInstallColormap(ColormapPtr pmap) } (*pmap->pScreen->StoreColors) (pmap, entries, defs); +out: free(ppix); free(prgb); free(defs);