ruby-changes:52538
From: nobu <ko1@a...>
Date: Sat, 15 Sep 2018 18:59:20 +0900 (JST)
Subject: [ruby-changes:52538] nobu:r64750 (trunk): Fix issues detected by code analysis tool (mainly Coverity).
nobu 2018-09-15 18:59:14 +0900 (Sat, 15 Sep 2018) New Revision: 64750 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64750 Log: 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@r...> Modified files: trunk/addr2line.c trunk/regcomp.c Index: regcomp.c =================================================================== --- regcomp.c (revision 64749) +++ regcomp.c (revision 64750) @@ -3596,6 +3596,7 @@ expand_case_fold_string(Node* node, rege https://github.com/ruby/ruby/blob/trunk/regcomp.c#L3596 if (n == 0 || varlen == 0) { if (IS_NULL(snode)) { if (IS_NULL(root) && IS_NOT_NULL(prev_node)) { + onig_node_free(top_root); top_root = root = onig_node_list_add(NULL_NODE, prev_node); if (IS_NULL(root)) { onig_node_free(prev_node); @@ -3627,6 +3628,7 @@ expand_case_fold_string(Node* node, rege https://github.com/ruby/ruby/blob/trunk/regcomp.c#L3628 } } if (IS_NULL(root) && IS_NOT_NULL(prev_node)) { + onig_node_free(top_root); top_root = root = onig_node_list_add(NULL_NODE, prev_node); if (IS_NULL(root)) { onig_node_free(prev_node); @@ -3677,6 +3679,7 @@ expand_case_fold_string(Node* node, rege https://github.com/ruby/ruby/blob/trunk/regcomp.c#L3679 if (r != 0) goto mem_err; if (IS_NOT_NULL(prev_node) && IS_NULL(root)) { + onig_node_free(top_root); top_root = root = onig_node_list_add(NULL_NODE, prev_node); if (IS_NULL(root)) { onig_node_free(srem); Index: addr2line.c =================================================================== --- addr2line.c (revision 64749) +++ addr2line.c (revision 64750) @@ -633,11 +633,12 @@ fill_lines(int num_traces, void **traces https://github.com/ruby/ruby/blob/trunk/addr2line.c#L633 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 https://github.com/ruby/ruby/blob/trunk/addr2line.c#L706 finish: return dladdr_fbase; fail: + if (file != NULL) { + munmap(file, (size_t)filesize); + } return (uintptr_t)-1; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/