[binutils-gdb] Re: Sanity check read_section_stabs_debugging_info

Alan Modra amodra@sourceware.org
Thu Mar 16 00:58:49 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d56e433a7914cdf1ad6db64f7b10506336a8def9

commit d56e433a7914cdf1ad6db64f7b10506336a8def9
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Mar 15 10:26:24 2023 +1030

    Re: Sanity check read_section_stabs_debugging_info
    
            * rddbg.c (read_section_stabs_debugging_info): Don't segfault on
            zero size string section.

Diff:
---
 binutils/rddbg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/binutils/rddbg.c b/binutils/rddbg.c
index f2ed6bcb3dd..1a888778312 100644
--- a/binutils/rddbg.c
+++ b/binutils/rddbg.c
@@ -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);


More information about the Binutils-cvs mailing list