public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* libctf: Avoid use of uninitialised variables
@ 2022-08-01  0:02 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-08-01  0:02 UTC (permalink / raw)
  To: binutils

	* ctf-link.c (ctf_link_add_ctf_internal): Don't free uninitialised
	pointers.

diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
index f2317302e26..702f2b4d5fe 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);
 }
 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-01  0:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-01  0:02 libctf: Avoid use of uninitialised variables Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).