diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 4ca494778e..65f30632c3 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1274,13 +1274,13 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd std::vector codeSections = reader.GetCodeSections(); for (SectionID id : codeSections) { u32 start = reader.GetSectionAddr(id); - if (!Memory::IsValidAddress(start)) { - ERROR_LOG(LOADER, "Bad section addr %08x of section %d", start, id); - continue; - } - // Note: scan end is inclusive. u32 end = start + reader.GetSectionSize(id) - 4; + u32 len = end + 4 - start; + if (!Memory::IsValidRange(start, len)) { + ERROR_LOG(LOADER, "Bad section %08x (len %08x) of section %d", start, len, id); + continue; + } if (start < module->textStart) module->textStart = start;