diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-15 09:59:14 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-15 09:59:14 +0000 |
commit | 893949167bdb911c7db9fd59de85f288c09741e1 (patch) | |
tree | 5d0c3b38867d5ffa219e85584187628ba86de1af /addr2line.c | |
parent | 958817d50da2738317da85894d7e0331a306d2f0 (diff) |
Fix issues detected by code analysis tool (mainly Coverity).
* Fix leaked storage in addr2line.c.
* Fix for "top_root" leaking the resource.
[Fix GH-1956]
From: Jun Aruga <jaruga@redhat.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'addr2line.c')
-rw-r--r-- | addr2line.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/addr2line.c b/addr2line.c index 2c422cc169..b266e44d5d 100644 --- a/addr2line.c +++ b/addr2line.c @@ -633,11 +633,12 @@ fill_lines(int num_traces, void **traces, int check_debuglink, h = dlopen(NULL, RTLD_NOW|RTLD_LOCAL); if (!h) continue; s = dlsym(h, strtab + sym->st_name); - if (!s) continue; - if (dladdr(s, &info)) { + if (s && dladdr(s, &info)) { dladdr_fbase = (uintptr_t)info.dli_fbase; + dlclose(h); break; } + dlclose(h); } if (ehdr->e_type == ET_EXEC) { obj->base_addr = 0; @@ -705,6 +706,9 @@ fill_lines(int num_traces, void **traces, int check_debuglink, finish: return dladdr_fbase; fail: + if (file != NULL) { + munmap(file, (size_t)filesize); + } return (uintptr_t)-1; } |