diff options
| author | Mark Wielaard <[email protected]> | 2013-12-23 23:21:59 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2013-12-31 13:58:32 +0100 |
| commit | b20ca0bd7fba0743fa97df2d42f6fd3c7b206039 (patch) | |
| tree | 1476cecc4bf2b87fdf52c02e90d781dc6bc78645 | |
| parent | a6141d27691a68a4af5eb48ab10d27e74d3c2a6b (diff) | |
libdwfl: Fix build_id memory leak in dwfl_segment_report_module.
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 <[email protected]>
| -rw-r--r-- | libdwfl/ChangeLog | 5 | ||||
| -rw-r--r-- | libdwfl/dwfl_segment_report_module.c | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 8e50f2f2..807fc2b1 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,5 +1,10 @@ 2013-12-23 Mark Wielaard <[email protected]> + * dwfl_segment_report_module.c (dwfl_segment_report_module): Free + build_id before returning early. + +2013-12-23 Mark Wielaard <[email protected]> + * linux-pid-attach.c (__libdwfl_attach_state_for_pid): Report actual pid (thread group leader) to dwfl_attach_state. diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 55f6d388..fd967e9a 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -427,7 +427,10 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, /* 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; @@ -519,7 +522,10 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, } } if (skip_this_module) - return finish (); + { + free (build_id); + return finish (); + } } /* Our return value now says to skip the segments contained |
