diff --git a/CHANGES b/CHANGES index 7d73e5288..53113ed4d 100644 --- a/CHANGES +++ b/CHANGES @@ -39,6 +39,7 @@ Other fixes: - All: Improve export headers (fixes mgba.io/i/1738) - Core: Ensure ELF regions can be written before trying - Core: Fix reported ROM size when a fixed buffer size is used + - Core: Fix memory leak loading ELF files - Debugger: Don't skip undefined instructions when debugger attached - FFmpeg: Fix some small memory leaks - FFmpeg: Fix encoding of time base diff --git a/src/core/core.c b/src/core/core.c index 76c97a927..3b82e76cb 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -387,9 +387,11 @@ bool mCoreLoadELF(struct mCore* core, struct ELF* elf) { if (block && bsize >= phdr->p_filesz && esize > phdr->p_offset && esize >= phdr->p_filesz + phdr->p_offset) { memcpy(block, &bytes[phdr->p_offset], phdr->p_filesz); } else { + ELFProgramHeadersDeinit(&ph); return false; } } + ELFProgramHeadersDeinit(&ph); return true; }