From a53acd9f27065ba778f7b7117f6d53f8a1f80b89 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 10 Apr 2025 19:16:56 +0200 Subject: [PATCH] dbe: 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 --- dbe/dbe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbe/dbe.c b/dbe/dbe.c index 0cf4c7df2..b9c57b884 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -1305,7 +1305,7 @@ DbeExtensionInit(void) pScreen = screenInfo.screens[i]; - if (!(pDbeScreenPriv = malloc(sizeof(DbeScreenPrivRec)))) { + if (!(pDbeScreenPriv = calloc(1, sizeof(DbeScreenPrivRec)))) { /* If we can not alloc a window or screen private, * then free any privates that we already alloc'ed and return */