From 0b796bdfe413f0405d390d40c07d69ae4ae8b5b3 Mon Sep 17 00:00:00 2001 From: Spike Date: Thu, 28 Jun 2018 05:32:43 +0100 Subject: [PATCH] Fixed issue with Z_Realloc not guarenteeing 0-filled memory (due to alignment). --- quakespasm/Quake/zone.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/quakespasm/Quake/zone.c b/quakespasm/Quake/zone.c index 05936bb1..9ab8cfe2 100644 --- a/quakespasm/Quake/zone.c +++ b/quakespasm/Quake/zone.c @@ -237,6 +237,12 @@ void *Z_Realloc(void *ptr, int size) if (!ptr) Sys_Error ("Z_Realloc: failed on allocation of %i bytes", size); + //Spike -- fix a bug where alignment resulted in no 0-initialisation + block = (memblock_t *) ((byte *) ptr - sizeof (memblock_t)); + size = block->size; + size -= (4 + (int)sizeof(memblock_t)); /* see Z_TagMalloc() */ + //Spike -- end fix + if (ptr != old_ptr) memmove (ptr, old_ptr, q_min(old_size, size)); if (old_size < size)