From df16e041deafa1d7fe7d8e65c02213b885c60a8e Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 22 Jul 2020 16:07:48 +0100 Subject: 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. --- libctf/ctf-archive.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'libctf/ctf-archive.c') 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); -- cgit v1.1