From 893949167bdb911c7db9fd59de85f288c09741e1 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 15 Sep 2018 09:59:14 +0000 Subject: 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- addr2line.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'addr2line.c') diff --git a/addr2line.c b/addr2line.c index 2c422cc..b266e44 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; } -- cgit v1.1