aboutsummaryrefslogtreecommitdiff
path: root/libbacktrace/elf.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-01-31 23:23:21 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-01-31 23:23:21 +0000
commit65d0b859909d306e498ba5dc62c15d5b9e7ac81c (patch)
treef8f63ae3f16e9ee325b8f57ba0f5cc31f18acba7 /libbacktrace/elf.c
parentbcbe891cd60adcb54eaf9ac2a993bb666f513b2c (diff)
downloadgcc-65d0b859909d306e498ba5dc62c15d5b9e7ac81c.zip
gcc-65d0b859909d306e498ba5dc62c15d5b9e7ac81c.tar.gz
gcc-65d0b859909d306e498ba5dc62c15d5b9e7ac81c.tar.bz2
elf.c (elf_add): Close descriptor if we use a debugfile.
* elf.c (elf_add): Close descriptor if we use a debugfile. * btest.c (check_open_files): New static function. (main): Call check_open_files. From-SVN: r257275
Diffstat (limited to 'libbacktrace/elf.c')
-rw-r--r--libbacktrace/elf.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 6403c08..3ee1dbe 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -2929,12 +2929,19 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
error_callback, data);
if (d >= 0)
{
+ int ret;
+
backtrace_release_view (state, &buildid_view, error_callback, data);
if (debuglink_view_valid)
backtrace_release_view (state, &debuglink_view, error_callback,
data);
- return elf_add (state, NULL, d, base_address, error_callback, data,
- fileline_fn, found_sym, found_dwarf, 0, 1);
+ ret = elf_add (state, NULL, d, base_address, error_callback, data,
+ fileline_fn, found_sym, found_dwarf, 0, 1);
+ if (ret < 0)
+ backtrace_close (d, error_callback, data);
+ else
+ backtrace_close (descriptor, error_callback, data);
+ return ret;
}
}
@@ -2953,10 +2960,17 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
data);
if (d >= 0)
{
+ int ret;
+
backtrace_release_view (state, &debuglink_view, error_callback,
data);
- return elf_add (state, NULL, d, base_address, error_callback, data,
- fileline_fn, found_sym, found_dwarf, 0, 1);
+ ret = elf_add (state, NULL, d, base_address, error_callback, data,
+ fileline_fn, found_sym, found_dwarf, 0, 1);
+ if (ret < 0)
+ backtrace_close (d, error_callback, data);
+ else
+ backtrace_close(descriptor, error_callback, data);
+ return ret;
}
}