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 | bbf88285ee3c326f267c42a3b090e440a0a07d90 (patch) | |
tree | 5d0c3b38867d5ffa219e85584187628ba86de1af /addr2line.c | |
parent | a783ee12db9915a2bc3738debef21e93cb470dd1 (diff) | |
download | ruby-bbf88285ee3c326f267c42a3b090e440a0a07d90.tar.gz |
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; } |