I've tested the patch. Now valgrind reports no leak. Tested-by: Masatake YAMATO <[email protected]>
> The result of dwarf_cfi_addrframe should have been freed when done. > Dwfl_Module cached the reloc_info and the eh_cfi it which also should > have been released when disposing of the module. > > Reported-by: Masatake YAMATO <[email protected]> > Signed-off-by: Mark Wielaard <[email protected]> > --- > libdwfl/ChangeLog | 7 +++++++ > libdwfl/dwfl_module.c | 6 ++++++ > libdwfl/frame_unwind.c | 1 + > 3 files changed, 14 insertions(+) > > diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog > index 7e87e17..79f65a4 100644 > --- a/libdwfl/ChangeLog > +++ b/libdwfl/ChangeLog > @@ -1,3 +1,10 @@ > +2013-12-14 Mark Wielaard <[email protected]> > + > + * dwfl_module.c (__libdwfl_module_free): Free mod->reloc_info if > + allocated. Call dwarf_cfi_end on mod->eh_cfi if necessary. > + * frame_unwind.c (handle_cfi): Free frame result from > + dwarf_cfi_addrframe when done. > + > 2013-11-30 Jan Kratochvil <[email protected]> > > Introduce process_attach_error. > diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c > index f914b3a..bb167ab 100644 > --- a/libdwfl/dwfl_module.c > +++ b/libdwfl/dwfl_module.c > @@ -84,6 +84,12 @@ __libdwfl_module_free (Dwfl_Module *mod) > if (mod->build_id_bits != NULL) > free (mod->build_id_bits); > > + if (mod->reloc_info != NULL) > + free (mod->reloc_info); > + > + if (mod->eh_cfi != NULL) > + dwarf_cfi_end (mod->eh_cfi); > + > free (mod->name); > free (mod); > } > diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c > index 1aed8cb..ad3a776 100644 > --- a/libdwfl/frame_unwind.c > +++ b/libdwfl/frame_unwind.c > @@ -576,6 +576,7 @@ handle_cfi (Dwfl_Frame *state, Dwarf_Addr pc, Dwarf_CFI > *cfi, Dwarf_Addr bias) > else > unwound->pc_state = DWFL_FRAME_STATE_PC_SET; > } > + free (frame); > } > > void > -- > 1.8.3.1 >
