diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index 1410a08c2e..9494604bd6 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -29,8 +29,8 @@ const char *ElfReader::GetSectionName(int section) const { return nullptr; int nameOffset = sections[section].sh_name; - if (nameOffset < 0) { // TODO: Where can we get a solid upper limit? - ERROR_LOG(LOADER, "ELF: Bad name offset %d in section %d", nameOffset, section); + if (nameOffset < 0 || nameOffset >= size_) { + ERROR_LOG(LOADER, "ELF: Bad name offset %d in section %d (max = %d)", nameOffset, section, (int)size_); return nullptr; } const char *ptr = (const char *)GetSectionDataPtr(header->e_shstrndx); diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 4431ad1a7a..2630cde19f 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1153,7 +1153,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd module->Cleanup(); kernelObjects.Destroy(module->GetUID()); error = SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE; - return 0; + return nullptr; } // Open ELF reader @@ -1167,7 +1167,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd module->Cleanup(); kernelObjects.Destroy(module->GetUID()); error = result; - return 0; + return nullptr; } module->memoryBlockAddr = reader.GetVaddr(); module->memoryBlockSize = reader.GetTotalSize();