mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-23 04:21:22 +00:00
Fixed issue with Z_Realloc not guarenteeing 0-filled memory (due to alignment).
This commit is contained in:
parent
50a7b25833
commit
0b796bdfe4
1 changed files with 6 additions and 0 deletions
|
@ -237,6 +237,12 @@ void *Z_Realloc(void *ptr, int size)
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
Sys_Error ("Z_Realloc: failed on allocation of %i bytes", size);
|
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)
|
if (ptr != old_ptr)
|
||||||
memmove (ptr, old_ptr, q_min(old_size, size));
|
memmove (ptr, old_ptr, q_min(old_size, size));
|
||||||
if (old_size < size)
|
if (old_size < size)
|
||||||
|
|
Loading…
Reference in a new issue