From: Alan Modra Date: Mon, 13 Mar 2023 23:55:51 +0000 (+1030) Subject: objdump segfault after symbol table error X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c8b3d02c49943d1fef2cc060dd7115a5ae5f7afe;p=binutils-gdb.git objdump segfault after symbol table error This memcpy segfaults if symcount is -1 (=> syms is NULL). memcpy (sorted_syms, symcount ? syms : dynsyms, sorted_symcount * sizeof (asymbol *)); * objdump.c (slurp_symtab): Don't leave symcount as -1 after an error. (slurp_dynamic_symtab): Likewise for dynsymcount. --- diff --git a/binutils/objdump.c b/binutils/objdump.c index 0e8e1980b80..5dac13ba868 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -1015,6 +1015,7 @@ slurp_symtab (bfd *abfd) my_bfd_nonfatal (bfd_get_filename (abfd)); free (sy); sy = NULL; + symcount = 0; } return sy; } @@ -1048,6 +1049,7 @@ slurp_dynamic_symtab (bfd *abfd) my_bfd_nonfatal (bfd_get_filename (abfd)); free (sy); sy = NULL; + dynsymcount = 0; } return sy; }