mirror of https://github.com/mgba-emu/mgba.git
Util: Fix crash reading invalid ELFs
This commit is contained in:
parent
d270a42de8
commit
d46f12aa8e
1
CHANGES
1
CHANGES
|
@ -23,6 +23,7 @@ Other fixes:
|
||||||
- Qt: Fix crash unloading shaders
|
- Qt: Fix crash unloading shaders
|
||||||
- Qt: Fix toggled actions on gamepads (fixes mgba.io/i/1650)
|
- Qt: Fix toggled actions on gamepads (fixes mgba.io/i/1650)
|
||||||
- Qt: Fix extraneous dialog (fixes mgba.io/i/1654)
|
- Qt: Fix extraneous dialog (fixes mgba.io/i/1654)
|
||||||
|
- Util: Fix crash reading invalid ELFs
|
||||||
Misc:
|
Misc:
|
||||||
- Qt: Renderer can be changed while a game is running
|
- Qt: Renderer can be changed while a game is running
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,9 @@ void ELFGetProgramHeaders(struct ELF* elf, struct ELFProgramHeaders* ph) {
|
||||||
ELFProgramHeadersClear(ph);
|
ELFProgramHeadersClear(ph);
|
||||||
Elf32_Ehdr* hdr = elf32_getehdr(elf->e);
|
Elf32_Ehdr* hdr = elf32_getehdr(elf->e);
|
||||||
Elf32_Phdr* phdr = elf32_getphdr(elf->e);
|
Elf32_Phdr* phdr = elf32_getphdr(elf->e);
|
||||||
|
if (!hdr || !phdr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ELFProgramHeadersResize(ph, hdr->e_phnum);
|
ELFProgramHeadersResize(ph, hdr->e_phnum);
|
||||||
memcpy(ELFProgramHeadersGetPointer(ph, 0), phdr, sizeof(*phdr) * hdr->e_phnum);
|
memcpy(ELFProgramHeadersGetPointer(ph, 0), phdr, sizeof(*phdr) * hdr->e_phnum);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue