From f92ecb61273bf58f9372f96868a9b8fb4d920ad4 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Tue, 2 Apr 2013 21:17:18 -0700 Subject: [PATCH] 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 --- src/dwarf/Gparser.c | 11 ++++++----- 1 file 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; }