|
|
f8d165 |
From 893949167bdb911c7db9fd59de85f288c09741e1 Mon Sep 17 00:00:00 2001
|
|
|
f8d165 |
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
|
|
|
f8d165 |
Date: Sat, 15 Sep 2018 09:59:14 +0000
|
|
|
f8d165 |
Subject: [PATCH] Fix issues detected by code analysis tool (mainly Coverity).
|
|
|
f8d165 |
|
|
|
f8d165 |
* Fix leaked storage in addr2line.c.
|
|
|
f8d165 |
* Fix for "top_root" leaking the resource.
|
|
|
f8d165 |
|
|
|
f8d165 |
[Fix GH-1956]
|
|
|
f8d165 |
|
|
|
f8d165 |
From: Jun Aruga <jaruga@redhat.com>
|
|
|
f8d165 |
|
|
|
f8d165 |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
f8d165 |
---
|
|
|
f8d165 |
addr2line.c | 8 ++++++--
|
|
|
f8d165 |
regcomp.c | 3 +++
|
|
|
f8d165 |
2 files changed, 9 insertions(+), 2 deletions(-)
|
|
|
f8d165 |
|
|
|
f8d165 |
diff --git a/addr2line.c b/addr2line.c
|
|
|
f8d165 |
index 2c422cc1697a..b266e44d5d4b 100644
|
|
|
f8d165 |
--- a/addr2line.c
|
|
|
f8d165 |
+++ b/addr2line.c
|
|
|
f8d165 |
@@ -593,11 +593,12 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
|
|
|
f8d165 |
h = dlopen(NULL, RTLD_NOW|RTLD_LOCAL);
|
|
|
f8d165 |
if (!h) continue;
|
|
|
f8d165 |
s = dlsym(h, strtab + sym->st_name);
|
|
|
f8d165 |
- if (!s) continue;
|
|
|
f8d165 |
- if (dladdr(s, &info)) {
|
|
|
f8d165 |
+ if (s && dladdr(s, &info)) {
|
|
|
f8d165 |
dladdr_fbase = (uintptr_t)info.dli_fbase;
|
|
|
f8d165 |
+ dlclose(h);
|
|
|
f8d165 |
break;
|
|
|
f8d165 |
}
|
|
|
f8d165 |
+ dlclose(h);
|
|
|
f8d165 |
}
|
|
|
f8d165 |
if (ehdr->e_type == ET_EXEC) {
|
|
|
f8d165 |
obj->base_addr = 0;
|
|
|
f8d165 |
@@ -655,6 +656,9 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
|
|
|
f8d165 |
finish:
|
|
|
f8d165 |
return dladdr_fbase;
|
|
|
f8d165 |
fail:
|
|
|
f8d165 |
+ if (file != NULL) {
|
|
|
f8d165 |
+ munmap(file, (size_t)filesize);
|
|
|
f8d165 |
+ }
|
|
|
f8d165 |
return (uintptr_t)-1;
|
|
|
f8d165 |
}
|
|
|
f8d165 |
|
|
|
f8d165 |
diff --git a/regcomp.c b/regcomp.c
|
|
|
f8d165 |
index 0f6bee60d576..df7f73bac501 100644
|
|
|
f8d165 |
--- a/regcomp.c
|
|
|
f8d165 |
+++ b/regcomp.c
|
|
|
f8d165 |
@@ -3596,6 +3596,7 @@ expand_case_fold_string(Node* node, regex_t* reg)
|
|
|
f8d165 |
if (n == 0 || varlen == 0) {
|
|
|
f8d165 |
if (IS_NULL(snode)) {
|
|
|
f8d165 |
if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {
|
|
|
f8d165 |
+ onig_node_free(top_root);
|
|
|
f8d165 |
top_root = root = onig_node_list_add(NULL_NODE, prev_node);
|
|
|
f8d165 |
if (IS_NULL(root)) {
|
|
|
f8d165 |
onig_node_free(prev_node);
|
|
|
f8d165 |
@@ -3627,6 +3628,7 @@ expand_case_fold_string(Node* node, regex_t* reg)
|
|
|
f8d165 |
}
|
|
|
f8d165 |
}
|
|
|
f8d165 |
if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {
|
|
|
f8d165 |
+ onig_node_free(top_root);
|
|
|
f8d165 |
top_root = root = onig_node_list_add(NULL_NODE, prev_node);
|
|
|
f8d165 |
if (IS_NULL(root)) {
|
|
|
f8d165 |
onig_node_free(prev_node);
|
|
|
f8d165 |
@@ -3677,6 +3679,7 @@ expand_case_fold_string(Node* node, regex_t* reg)
|
|
|
f8d165 |
if (r != 0) goto mem_err;
|
|
|
f8d165 |
|
|
|
f8d165 |
if (IS_NOT_NULL(prev_node) && IS_NULL(root)) {
|
|
|
f8d165 |
+ onig_node_free(top_root);
|
|
|
f8d165 |
top_root = root = onig_node_list_add(NULL_NODE, prev_node);
|
|
|
f8d165 |
if (IS_NULL(root)) {
|
|
|
f8d165 |
onig_node_free(srem);
|
|
|
f8d165 |
--
|
|
|
f8d165 |
2.21.0
|
|
|
f8d165 |
|