Skip to content

Commit 6f4f2bd

Browse files
committed
Handle OOM case for result object.
1 parent 44ae72d commit 6f4f2bd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

MemoryModule.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,14 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data,
378378
}
379379

380380
result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), 0, sizeof(MEMORYMODULE));
381+
if (result == NULL) {
382+
#if DEBUG_OUTPUT
383+
OutputLastError("Can't reserve memory");
384+
#endif
385+
VirtualFree(code, 0, MEM_RELEASE);
386+
return NULL;
387+
}
388+
381389
result->codeBase = code;
382390
result->numModules = 0;
383391
result->modules = NULL;

0 commit comments

Comments
 (0)