summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Sharma <asharma@fb.com>2013-04-02 21:17:18 -0700
committerArun Sharma <asharma@fb.com>2013-04-02 21:19:56 -0700
commitf92ecb61273bf58f9372f96868a9b8fb4d920ad4 (patch)
tree1c62d04d19f1b92ab3bbc9d4c38cd9dafd3d5ab9
parent8028a537dd936d02204605065eaabf52be148294 (diff)
downloadlibunwind-f92ecb61273bf58f9372f96868a9b8fb4d920ad4.tar.gz
dwarf: Fix memory leak
Need to clean up by calling put_unwind_info() on code paths where fetch_proc_info() fails. Signed-off-by: Arun Sharma <asharma@fb.com>
-rw-r--r--src/dwarf/Gparser.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c
index 49c79db1..0f9c2218 100644
--- a/src/dwarf/Gparser.c
+++ b/src/dwarf/Gparser.c
@@ -460,9 +460,6 @@ parse_dynamic (struct dwarf_cursor *c, unw_word_t ip, dwarf_state_record_t *sr)
static inline void
put_unwind_info (struct dwarf_cursor *c, unw_proc_info_t *pi)
{
- if (!c->pi_valid)
- return;
-
if (c->pi_is_dynamic)
unwi_put_dynamic_unwind_info (c->as, pi, c->as_arg);
else if (pi->unwind_info)
@@ -824,7 +821,10 @@ uncached_dwarf_find_save_locs (struct dwarf_cursor *c)
int ret;
if ((ret = fetch_proc_info (c, c->ip, 1)) < 0)
- return ret;
+ {
+ put_unwind_info (c, &c->pi);
+ return ret;
+ }
if ((ret = create_state_record_for (c, &sr, c->ip)) < 0)
return ret;
@@ -863,7 +863,8 @@ dwarf_find_save_locs (struct dwarf_cursor *c)
if ((ret = fetch_proc_info (c, c->ip, 1)) < 0 ||
(ret = create_state_record_for (c, &sr, c->ip)) < 0)
{
- put_rs_cache (c->as, cache, &saved_mask);
+ put_rs_cache (c->as, cache, &saved_mask);
+ put_unwind_info (c, &c->pi);
return ret;
}