all repos — mgba @ 343812e9e6b1d3979121a89e6f58b8908f9c2cdf

mGBA Game Boy Advance Emulator

Core: Fix memory leak loading ELF files
Vicki Pfau vi@endrift.com
Mon, 17 Aug 2020 01:00:36 -0700
commit

343812e9e6b1d3979121a89e6f58b8908f9c2cdf

parent

f4522c3942f45fd3e9711ec2e723ac288cf51377

2 files changed, 3 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -39,6 +39,7 @@ - 3DS: Fix crash with libctru 2.0 when exiting

- 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
M src/core/core.csrc/core/core.c

@@ -387,9 +387,11 @@ char* bytes = ELFBytes(elf, &esize);

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; }