diff options
author | Alan Modra <amodra@gmail.com> | 2022-07-31 22:51:55 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-08-01 09:40:01 +0930 |
commit | 27b28c705cf0412e5e7ddcf954352691fe5ba6ef (patch) | |
tree | 1442c3130625fd9d41a5433c0cec341f300b9951 /libctf | |
parent | b336123a087f9a85e7b24d7e420bd44b9c9d3552 (diff) | |
download | gdb-27b28c705cf0412e5e7ddcf954352691fe5ba6ef.zip gdb-27b28c705cf0412e5e7ddcf954352691fe5ba6ef.tar.gz gdb-27b28c705cf0412e5e7ddcf954352691fe5ba6ef.tar.bz2 |
libctf: Avoid use of uninitialised variables
* ctf-link.c (ctf_link_add_ctf_internal): Don't free uninitialised
pointers.
(cherry picked from commit 9ea6fffe1ebec9bd1929c708e044b765eabea258)
Diffstat (limited to 'libctf')
-rw-r--r-- | libctf/ctf-link.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c index f231730..702f2b4 100644 --- a/libctf/ctf-link.c +++ b/libctf/ctf-link.c @@ -114,7 +114,7 @@ ctf_link_add_ctf_internal (ctf_dict_t *fp, ctf_archive_t *ctf, goto oom; if ((input = calloc (1, sizeof (ctf_link_input_t))) == NULL) - goto oom; + goto oom1; input->clin_arc = ctf; input->clin_fp = fp_input; @@ -125,19 +125,23 @@ ctf_link_add_ctf_internal (ctf_dict_t *fp, ctf_archive_t *ctf, { if (asprintf (&keyname, "%s#%li", name, (long int) ctf_dynhash_elements (fp->ctf_link_inputs)) < 0) - goto oom; + goto oom2; } else if ((keyname = strdup (name)) == NULL) - goto oom; + goto oom2; if (ctf_dynhash_insert (fp->ctf_link_inputs, keyname, input) < 0) - goto oom; + goto oom3; return 0; - oom: + + oom3: + free (keyname); + oom2: free (input); + oom1: free (filename); - free (keyname); + oom: return ctf_set_errno (fp, ENOMEM); } |