From 6f4f2bdd5bee729598e5e3c28b973459342ee72f Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Fri, 8 Mar 2013 23:58:49 +0100 Subject: [PATCH] Handle OOM case for result object. --- MemoryModule.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MemoryModule.c b/MemoryModule.c index 96020f4..1b3af1f 100644 --- a/MemoryModule.c +++ b/MemoryModule.c @@ -378,6 +378,14 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data, } result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), 0, sizeof(MEMORYMODULE)); + if (result == NULL) { +#if DEBUG_OUTPUT + OutputLastError("Can't reserve memory"); +#endif + VirtualFree(code, 0, MEM_RELEASE); + return NULL; + } + result->codeBase = code; result->numModules = 0; result->modules = NULL;