]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
coff_get_normalized_symtab bfd_release
authorAlan Modra <amodra@gmail.com>
Tue, 21 Mar 2023 23:43:46 +0000 (10:13 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 22 Mar 2023 00:15:32 +0000 (10:45 +1030)
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.

* coffgen.c (coff_get_normalized_symtab): Don't bfd_release on
error.

(cherry picked from commit bcefc6be9754d45fb9391993e6daaf01a68d9bd5)

bfd/coffgen.c

index 74636a9e3051a8151f32c99b457dee69ae3f87e6..e9455c82a33687859a053e7a45a012b95168eb4f 100644 (file)
@@ -1756,10 +1756,7 @@ coff_get_normalized_symtab (bfd *abfd)
 
       /* PR 17512: Prevent buffer overrun.  */
       if (symbol_ptr->u.syment.n_numaux > ((raw_end - 1) - raw_src) / symesz)
-       {
-         bfd_release (abfd, internal);
-         return NULL;
-       }
+       return NULL;
 
       for (i = 0;
           i < symbol_ptr->u.syment.n_numaux;