Skip to content

Commit

Permalink
Merge pull request #364 from laqieer/master
Browse files Browse the repository at this point in the history
bugfix: crash when loading elf
  • Loading branch information
ZachBacon committed Feb 5, 2019
2 parents eb6dfb4 + 7b350c0 commit ed29b9c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/gba/elf.cpp
Expand Up @@ -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",
Expand Down

0 comments on commit ed29b9c

Please sign in to comment.