diff --git a/CHANGES b/CHANGES index 3058e1b1d..35d1a9a91 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ Other fixes: - CMake: Link with correct OpenGL library (fixes mgba.io/i/1872) - Core: Fix threading improperly setting paused state while interrupted - Core: Fix thread unsafety issue when dispatching code to a thread + - Core: Fix loading ELF files that have unexpected empty program headers - Debugger: Close trace log when done tracing - Qt: Fix running proxied video if it gets pushed to the main thread - Qt: Fix game display sometimes disappearing after closing load/save state screen diff --git a/src/core/core.c b/src/core/core.c index 82b31c7af..c2f6ffa99 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -371,6 +371,9 @@ bool mCoreLoadELF(struct mCore* core, struct ELF* elf) { for (i = 0; i < ELFProgramHeadersSize(&ph); ++i) { size_t bsize, esize; Elf32_Phdr* phdr = ELFProgramHeadersGetPointer(&ph, i); + if (!phdr->p_filesz) { + continue; + } void* block = mCoreGetMemoryBlock(core, phdr->p_paddr, &bsize); char* bytes = ELFBytes(elf, &esize); if (block && bsize >= phdr->p_filesz && esize > phdr->p_offset && esize >= phdr->p_filesz + phdr->p_offset) {