From 7b350c09b9241a292d719df33d2bc9c56d75fcc8 Mon Sep 17 00:00:00 2001 From: laqieer Date: Tue, 5 Feb 2019 20:42:27 +0800 Subject: [PATCH] bugfix: crash when loading elf --- src/gba/elf.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gba/elf.cpp b/src/gba/elf.cpp index d9d3b370..b1099f53 100644 --- a/src/gba/elf.cpp +++ b/src/gba/elf.cpp @@ -2604,18 +2604,18 @@ bool elfReadProgram(ELFHeader* eh, uint8_t* data, unsigned long data_size, int& sh = (ELFSectionHeader**) malloc(sizeof(ELFSectionHeader*) * count); - stringTable = (char*)elfReadSection(data, sh[READ16LE(&eh->e_shstrndx)]); - - elfSectionHeaders = sh; - elfSectionHeadersStringTable = stringTable; - elfSectionHeadersCount = count; - for (i = 0; i < count; i++) { sh[i] = (ELFSectionHeader*)p; p += sizeof(ELFSectionHeader); if (READ16LE(&eh->e_shentsize) != sizeof(ELFSectionHeader)) p += READ16LE(&eh->e_shentsize) - sizeof(ELFSectionHeader); } + + stringTable = (char*)elfReadSection(data, sh[READ16LE(&eh->e_shstrndx)]); + + elfSectionHeaders = sh; + elfSectionHeadersStringTable = stringTable; + elfSectionHeadersCount = count; for (i = 0; i < count; i++) { // printf("SH %d %-20s %08x %08x %08x %08x %08x %08x %08x %08x\n",