Merge pull request #364 from laqieer/master

bugfix: crash when loading elf
This commit is contained in:
Zach Bacon 2019-02-05 08:11:25 -05:00 committed by GitHub
commit ed29b9c497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -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",