Skip to content

Commit 36574a5

Browse files
committed
Handle case where resource to load is NULL.
1 parent 463447c commit 36574a5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

MemoryModule.c

+6
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,9 @@ HMEMORYRSRC MemoryFindResourceEx(HMEMORYMODULE module, LPCTSTR name, LPCTSTR typ
825825
DWORD MemorySizeofResource(HMEMORYMODULE module, HMEMORYRSRC resource)
826826
{
827827
PIMAGE_RESOURCE_DATA_ENTRY entry = (PIMAGE_RESOURCE_DATA_ENTRY) resource;
828+
if (entry == NULL) {
829+
return 0;
830+
}
828831

829832
return entry->Size;
830833
}
@@ -833,6 +836,9 @@ LPVOID MemoryLoadResource(HMEMORYMODULE module, HMEMORYRSRC resource)
833836
{
834837
unsigned char *codeBase = ((PMEMORYMODULE) module)->codeBase;
835838
PIMAGE_RESOURCE_DATA_ENTRY entry = (PIMAGE_RESOURCE_DATA_ENTRY) resource;
839+
if (entry == NULL) {
840+
return NULL;
841+
}
836842

837843
return codeBase + entry->OffsetToData;
838844
}

0 commit comments

Comments
 (0)