libdwfl: Always clean up build_id.memory
authorMark Wielaard <mark@klomp.org>
Mon, 20 Dec 2021 23:55:27 +0000 (00:55 +0100)
committerMark Wielaard <mark@klomp.org>
Tue, 21 Dec 2021 10:41:01 +0000 (11:41 +0100)
commit4fdd85881c8acd06db737c45ea6aabc60aef3d4d
treeac6334831bc8acb641a56f6ad80f8daf15126313
parent8f8c78cc885d83f999f952dfaa2c2e4595b38f83
libdwfl: Always clean up build_id.memory

There was a small memory leak if an error was detected in some places
in dwfl_segment_report_module after the build_id.memory was alredy
allocated. Fix this by moving initialization of struct elf_build_id
early and always free the memory, if not NULL, at exit.

https://sourceware.org/bugzilla/show_bug.cgi?id=28685

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdwfl/ChangeLog
libdwfl/dwfl_segment_report_module.c