Re: Sanity check read_section_stabs_debugging_info
authorAlan Modra <amodra@gmail.com>
Tue, 14 Mar 2023 23:56:24 +0000 (10:26 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 16 Mar 2023 00:41:44 +0000 (11:11 +1030)
* rddbg.c (read_section_stabs_debugging_info): Don't segfault on
zero size string section.

binutils/rddbg.c

index f2ed6bcb3ddc9fc0014b59deb84f7a84f9434869..1a888778312e218629769bab69a1c0ba578d165e 100644 (file)
@@ -147,7 +147,8 @@ read_section_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount,
            }
          /* Zero terminate the strings table, just in case.  */
          strsize = bfd_section_size (strsec);
-         strings [strsize - 1] = 0;
+         if (strsize != 0)
+           strings [strsize - 1] = 0;
          if (shandle == NULL)
            {
              shandle = start_stab (dhandle, abfd, true, syms, symcount);