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