aboutsummaryrefslogtreecommitdiff
path: root/binutils/readelf.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 /binutils/readelf.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 'binutils/readelf.c')
-rw-r--r--binutils/readelf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 2406304..c3cbd2c 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4827,12 +4827,15 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
request_dump (dumpdata, CTF_DUMP);
break;
case OPTION_CTF_SYMBOLS:
+ free (dump_ctf_symtab_name);
dump_ctf_symtab_name = strdup (optarg);
break;
case OPTION_CTF_STRINGS:
+ free (dump_ctf_strtab_name);
dump_ctf_strtab_name = strdup (optarg);
break;
case OPTION_CTF_PARENT:
+ free (dump_ctf_parent_name);
dump_ctf_parent_name = strdup (optarg);
break;
case OPTION_DYN_SYMS:
@@ -14296,7 +14299,7 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
symsectp = shdr_to_ctf_sect (&symsect, symtab_sec, filedata);
symsect.cts_data = symdata;
}
- if (dump_ctf_strtab_name && dump_ctf_symtab_name[0] != 0)
+ if (dump_ctf_strtab_name && dump_ctf_strtab_name[0] != 0)
{
if ((strtab_sec = find_section (filedata, dump_ctf_strtab_name)) == NULL)
{