From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 931C3384B0DD; Mon, 1 Aug 2022 00:02:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 931C3384B0DD Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] libctf: Avoid use of uninitialised variables X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 1a5178fe284547ef2abd8ae66588c9999d61c524 X-Git-Newrev: 9ea6fffe1ebec9bd1929c708e044b765eabea258 Message-Id: <20220801000232.931C3384B0DD@sourceware.org> Date: Mon, 1 Aug 2022 00:02:32 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 00:02:32 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9ea6fffe1ebe= c9bd1929c708e044b765eabea258 commit 9ea6fffe1ebec9bd1929c708e044b765eabea258 Author: Alan Modra Date: Sun Jul 31 22:51:55 2022 +0930 libctf: Avoid use of uninitialised variables =20 * ctf-link.c (ctf_link_add_ctf_internal): Don't free uninitiali= sed 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; =20 if ((input =3D calloc (1, sizeof (ctf_link_input_t))) =3D=3D NULL) - goto oom; + goto oom1; =20 input->clin_arc =3D ctf; input->clin_fp =3D fp_input; @@ -125,19 +125,23 @@ ctf_link_add_ctf_internal (ctf_dict_t *fp, ctf_archiv= e_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 =3D strdup (name)) =3D=3D NULL) - goto oom; + goto oom2; =20 if (ctf_dynhash_insert (fp->ctf_link_inputs, keyname, input) < 0) - goto oom; + goto oom3; =20 return 0; - oom: + + oom3: + free (keyname); + oom2: free (input); + oom1: free (filename); - free (keyname); + oom: return ctf_set_errno (fp, ENOMEM); }