From 8797c8c384bf8f9e5fc1785244ff8bfb1e57b3e3 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Fri, 27 Aug 2021 17:03:00 +0300 Subject: [PATCH] r_brush.c (AllocBlock): use calloc() to not leave uninitialized memory. keeps valgrind happy. --- Quake/r_brush.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Quake/r_brush.c b/Quake/r_brush.c index ec3dc572..ca21dfa6 100644 --- a/Quake/r_brush.c +++ b/Quake/r_brush.c @@ -726,9 +726,7 @@ int AllocBlock (int w, int h, int *x, int *y) lightmap_count++; lightmaps = (struct lightmap_s *) realloc(lightmaps, sizeof(*lightmaps)*lightmap_count); memset(&lightmaps[texnum], 0, sizeof(lightmaps[texnum])); - /* FIXME: we leave 'gaps' in malloc()ed data, CRC_Block() later accesses - * that uninitialized data and valgrind complains for it. use calloc() ? */ - lightmaps[texnum].data = (byte *) malloc(4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT); + lightmaps[texnum].data = (byte *) calloc(1, 4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT); //as we're only tracking one texture, we don't need multiple copies of allocated any more. memset(allocated, 0, sizeof(allocated)); }