From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 8517E384B0E6; Mon, 1 Aug 2022 01:08:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8517E384B0E6 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/binutils-2_39-branch] libctf: Avoid use of uninitialised variables X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/binutils-2_39-branch X-Git-Oldrev: b336123a087f9a85e7b24d7e420bd44b9c9d3552 X-Git-Newrev: 27b28c705cf0412e5e7ddcf954352691fe5ba6ef Message-Id: <20220801010855.8517E384B0E6@sourceware.org> Date: Mon, 1 Aug 2022 01:08:55 +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 01:08:55 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D27b28c705cf0= 412e5e7ddcf954352691fe5ba6ef commit 27b28c705cf0412e5e7ddcf954352691fe5ba6ef 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. =20 (cherry picked from commit 9ea6fffe1ebec9bd1929c708e044b765eabea258) 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); }