We might already have allocated memory to hold the build_id early in
consider_notes when we called consider_phdr for the program headers
we've read from the image. We would leak that memory when we don't use
it then because we return early/fail. This can be because either we
didn't find the correct bias or we skip the module because it would
conflict in address space with any already existing module of DWFL.
In both cases explicitly free the build_id memory.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-12-23 Mark Wielaard <mjw@redhat.com>
+ * dwfl_segment_report_module.c (dwfl_segment_report_module): Free
+ build_id before returning early.
+
+2013-12-23 Mark Wielaard <mjw@redhat.com>
+
* linux-pid-attach.c (__libdwfl_attach_state_for_pid): Report actual
pid (thread group leader) to dwfl_attach_state.
/* We must have seen the segment covering offset 0, or else the ELF
header we read at START was not produced by these program headers. */
if (unlikely (!found_bias))
- return finish ();
+ {
+ free (build_id);
+ return finish ();
+ }
/* Now we know enough to report a module for sure: its bounds. */
module_start += bias;
}
}
if (skip_this_module)
- return finish ();
+ {
+ free (build_id);
+ return finish ();
+ }
}
/* Our return value now says to skip the segments contained