Initial import
[external/libunwind.git] / packaging / dwarf_memleak.patch
1 From f92ecb61273bf58f9372f96868a9b8fb4d920ad4 Mon Sep 17 00:00:00 2001
2 From: Arun Sharma <asharma@fb.com>
3 Date: Tue, 2 Apr 2013 21:17:18 -0700
4 Subject: [PATCH] dwarf: Fix memory leak
5
6 Need to clean up by calling put_unwind_info() on code paths where fetch_proc_info() fails.
7
8 Signed-off-by: Arun Sharma <asharma@fb.com>
9 ---
10  src/dwarf/Gparser.c |   11 ++++++-----
11  1 files changed, 6 insertions(+), 5 deletions(-)
12
13 diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c
14 index 49c79db..0f9c221 100644
15 --- a/src/dwarf/Gparser.c
16 +++ b/src/dwarf/Gparser.c
17 @@ -460,9 +460,6 @@ parse_dynamic (struct dwarf_cursor *c, unw_word_t ip, dwarf_state_record_t *sr)
18  static inline void
19  put_unwind_info (struct dwarf_cursor *c, unw_proc_info_t *pi)
20  {
21 -  if (!c->pi_valid)
22 -    return;
23 -
24    if (c->pi_is_dynamic)
25      unwi_put_dynamic_unwind_info (c->as, pi, c->as_arg);
26    else if (pi->unwind_info)
27 @@ -824,7 +821,10 @@ uncached_dwarf_find_save_locs (struct dwarf_cursor *c)
28    int ret;
29  
30    if ((ret = fetch_proc_info (c, c->ip, 1)) < 0)
31 -    return ret;
32 +    {
33 +      put_unwind_info (c, &c->pi);
34 +      return ret;
35 +    }
36  
37    if ((ret = create_state_record_for (c, &sr, c->ip)) < 0)
38      return ret;
39 @@ -863,7 +863,8 @@ dwarf_find_save_locs (struct dwarf_cursor *c)
40        if ((ret = fetch_proc_info (c, c->ip, 1)) < 0 ||
41           (ret = create_state_record_for (c, &sr, c->ip)) < 0)
42         {
43 -         put_rs_cache (c->as, cache, &saved_mask);
44 +          put_rs_cache (c->as, cache, &saved_mask);
45 +          put_unwind_info (c, &c->pi);
46           return ret;
47         }
48  
49 -- 
50 1.7.2.5
51