If loading debug link is not successful, the initial NULL pointer for ei->image will eventually be restored, causing segfault during a later call to valid_object.
Move populating the prev_image and prev_size to after elf_map_image() to fix this. Signed-off-by: Hans-Christian Noren Egtvedt <[email protected]> --- src/elfxx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/elfxx.c b/src/elfxx.c index 48a08cd..b03dfcb 100644 --- a/src/elfxx.c +++ b/src/elfxx.c @@ -386,8 +386,8 @@ elf_w (load_debuglink) (const char* file, struct elf_image *ei, int is_local) { int ret; Elf_W (Shdr) *shdr; - Elf_W (Ehdr) *prev_image = ei->image; - off_t prev_size = ei->size; + Elf_W (Ehdr) *prev_image; + off_t prev_size; if (!ei->image) { @@ -396,6 +396,9 @@ elf_w (load_debuglink) (const char* file, struct elf_image *ei, int is_local) return ret; } + prev_image = ei->image; + prev_size = ei->size; + /* Ignore separate debug files which contain a .gnu_debuglink section. */ if (is_local == -1) { return 0; -- 2.14.1 _______________________________________________ Libunwind-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/libunwind-devel
