public inbox for binutils-cvs@sourceware.org
help / color / mirror / Atom feed
From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org
Subject: [binutils-gdb] libctf: Avoid use of uninitialised variables
Date: Mon,  1 Aug 2022 00:02:32 +0000 (GMT)	[thread overview]
Message-ID: <20220801000232.931C3384B0DD@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9ea6fffe1ebec9bd1929c708e044b765eabea258

commit 9ea6fffe1ebec9bd1929c708e044b765eabea258
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Jul 31 22:51:55 2022 +0930

    libctf: Avoid use of uninitialised variables
    
            * ctf-link.c (ctf_link_add_ctf_internal): Don't free uninitialised
            pointers.

Diff:
---
 libctf/ctf-link.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

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);
 }


                 reply	other threads:[~2022-08-01  0:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220801000232.931C3384B0DD@sourceware.org \
    --to=amodra@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).