dwarf-reader: fix undefined behaviour in get_binary_load_address
authorMatthias Maennich <maennich@google.com>
Thu, 18 Apr 2019 09:33:34 +0000 (11:33 +0200)
committerDodji Seketeli <dodji@redhat.com>
Thu, 18 Apr 2019 09:33:34 +0000 (11:33 +0200)
commit177f76ee3be44a88fced2788aabb835771c87c00
tree70b5f821b6428dee3ca246ba874f016ac2e94d0f
parent5d6af8d549fe9315ffb6d2c8a26b15795cee05b8
dwarf-reader: fix undefined behaviour in get_binary_load_address

Within the loop, the call `gelf_getphdr(elf_handle, i, &ph_mem)` is
returning a pointer to `ph_mem` that is only valid in this loop
iteration. The later assignment to *lowest_program_header and its
eventual use to assign load_address leads to undefined behaviour.

* src/abg-dwarf-reader.cc (get_binary_load_address): Move the
ph_mem and program_header variables out of the inner for-loop.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-dwarf-reader.cc