Skip to content

Commit 89e02fc

Browse files
committed
Zero the memory allocated in the heap
Using HEAP_ZERO_MEMORY parameter of HeapAlloc function we can fill all the struct contents with zeros thus removing possible bugs with uninitialized members and slightly shortening/speeding up the code
1 parent dc173ca commit 89e02fc

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

MemoryModule.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,17 +496,14 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data,
496496
}
497497
}
498498

499-
result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), 0, sizeof(MEMORYMODULE));
499+
result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MEMORYMODULE));
500500
if (result == NULL) {
501501
SetLastError(ERROR_OUTOFMEMORY);
502502
VirtualFree(code, 0, MEM_RELEASE);
503503
return NULL;
504504
}
505505

506506
result->codeBase = code;
507-
result->numModules = 0;
508-
result->modules = NULL;
509-
result->initialized = FALSE;
510507
result->isDLL = (old_header->FileHeader.Characteristics & IMAGE_FILE_DLL) != 0;
511508
result->loadLibrary = loadLibrary;
512509
result->getProcAddress = getProcAddress;

0 commit comments

Comments
 (0)