From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 057933858D38; Wed, 22 Mar 2023 00:15:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 057933858D38 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb/binutils-2_40-branch] coff_get_normalized_symtab bfd_release X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/binutils-2_40-branch X-Git-Oldrev: d180af460ba5f34f8f3b8f57319511617821846b X-Git-Newrev: 165accf07523db070eb25866a614b9a8f9c8e281 Message-Id: <20230322001549.057933858D38@sourceware.org> Date: Wed, 22 Mar 2023 00:15:49 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2023 00:15:49 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D165accf07523= db070eb25866a614b9a8f9c8e281 commit 165accf07523db070eb25866a614b9a8f9c8e281 Author: Alan Modra Date: Wed Mar 22 10:13:46 2023 +1030 coff_get_normalized_symtab bfd_release =20 We can't free "internal" on errors, since bfd_coff_swap_sym_in may call bfd_alloc. For example, _bfd_XXi_swap_sym_in may even create new sections, which use bfd_alloc'd memory. If "internal" is freed, all more recently bfd_alloc'd memory is also freed. =20 * coffgen.c (coff_get_normalized_symtab): Don't bfd_release on error. =20 (cherry picked from commit bcefc6be9754d45fb9391993e6daaf01a68d9bd5) Diff: --- bfd/coffgen.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 74636a9e305..e9455c82a33 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -1756,10 +1756,7 @@ coff_get_normalized_symtab (bfd *abfd) =20 /* PR 17512: Prevent buffer overrun. */ if (symbol_ptr->u.syment.n_numaux > ((raw_end - 1) - raw_src) / syme= sz) - { - bfd_release (abfd, internal); - return NULL; - } + return NULL; =20 for (i =3D 0; i < symbol_ptr->u.syment.n_numaux;