Better realloc zeroing

This commit is contained in:
Simon Lindholm 2022-06-29 15:24:58 +02:00
parent 81e85504de
commit 121bfb3939
1 changed files with 3 additions and 2 deletions

View File

@ -140,9 +140,10 @@ namespace kernel32 {
dwBytes = 1;
size_t oldSize = malloc_usable_size(hMem);
void *buffer = realloc(hMem, dwBytes);
if (buffer && (uFlags & 0x40) && dwBytes > oldSize) {
size_t newSize = malloc_usable_size(buffer);
if (buffer && (uFlags & 0x40) && newSize > oldSize) {
// GMEM_ZEROINT
memset((char*)buffer + oldSize, 0, malloc_usable_size(buffer) - oldSize);
memset((char*)buffer + oldSize, 0, newSize - oldSize);
}
return buffer;
}