aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-archive.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2020-07-22 16:07:48 +0100
committerNick Clifton <nickc@redhat.com>2020-07-22 16:07:48 +0100
commitdf16e041deafa1d7fe7d8e65c02213b885c60a8e (patch)
treee70b7fb09d95c52f99cdc93a4345a6c6b4c6bd3c /libctf/ctf-archive.c
parenta7b4ff4f0a0e503414b6b9a4184365fdb1f00fbe (diff)
downloadgdb-df16e041deafa1d7fe7d8e65c02213b885c60a8e.zip
gdb-df16e041deafa1d7fe7d8e65c02213b885c60a8e.tar.gz
gdb-df16e041deafa1d7fe7d8e65c02213b885c60a8e.tar.bz2
Fix problems in CTF handling code exposed by the Coverity static analysis tool.
readelf * readelf.c (parse_args): Silence potential warnings about a memory resource leak when allocating space for ctf option values. (dump_section_as_ctf): Fix typo checking dump_ctf_strtab_name variable. libctf * ctf-archive.c (ctf_arc_write): Avoid calling close twice on the same file descriptor.
Diffstat (limited to 'libctf/ctf-archive.c')
-rw-r--r--libctf/ctf-archive.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c
index ac13d6d..d857c01 100644
--- a/libctf/ctf-archive.c
+++ b/libctf/ctf-archive.c
@@ -228,23 +228,16 @@ ctf_arc_write (const char *file, ctf_file_t ** ctf_files, size_t ctf_file_cnt,
err = ctf_arc_write_fd (fd, ctf_files, ctf_file_cnt, names, threshold);
if (err)
- goto err;
+ goto err_close;
if ((err = close (fd)) < 0)
- {
- ctf_dprintf ("ctf_arc_write(): Cannot close after writing to archive: "
- "%s\n", strerror (errno));
- goto err_close;
- }
-
- err:
- close (fd);
- if (err < 0)
- unlink (file);
-
- return err;
+ ctf_dprintf ("ctf_arc_write(): Cannot close after writing to archive: "
+ "%s\n", strerror (errno));
+ goto err;
err_close:
+ (void) close (fd);
+ err:
if (err < 0)
unlink (file);