From fb3bbd5ec11f256f0538dd5b598446c79605fc7d Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 10 Apr 2025 19:13:18 +0200 Subject: [PATCH] fb: use calloc() instead of malloc() Using calloc() instead of malloc() as preventive measure, so there never can be any hidden bugs or leaks due uninitialized memory. The extra cost of using this compiler intrinsic should be practically impossible to measure - in many cases a good compiler can even deduce if certain areas really don't need to be zero'd (because they're written to right after allocation) and create more efficient machine code. The code pathes in question are pretty cold anyways, so it's probably not worth even thinking about potential extra runtime costs. Signed-off-by: Enrico Weigelt, metux IT consult --- fb/fboverlay.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fb/fboverlay.c b/fb/fboverlay.c index d8d9c2d75..5f5378bed 100644 --- a/fb/fboverlay.c +++ b/fb/fboverlay.c @@ -273,7 +273,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, int nvisuals; int ndepths; VisualID defaultVisual; - FbOverlayScrPrivPtr pScrPriv; if (!dixRegisterPrivateKey (&fbOverlayScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) @@ -282,7 +281,7 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, if (bpp1 == 24 || bpp2 == 24) return FALSE; - pScrPriv = malloc(sizeof(FbOverlayScrPrivRec)); + FbOverlayScrPrivPtr pScrPriv = calloc(1, sizeof(FbOverlayScrPrivRec)); if (!pScrPriv) return FALSE;