[binutils-gdb] memory leak in gas dwarf2dbg.c

Alan Modra amodra@sourceware.org
Wed Jan 1 12:46:09 GMT 2025


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

commit 50dd43e6e3614d337e85a36aaed8224124fe3087
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Jan 1 22:50:29 2025 +1030

    memory leak in gas dwarf2dbg.c
    
    Found when running the pr27355 testcase.
    
            PR 27355
            PR 27426
            * dwarf2dbg.c (allocate_filename_to_slot): Update dirs_in_use.

Diff:
---
 gas/dwarf2dbg.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index b84f5457949..2963e52958a 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -883,6 +883,8 @@ allocate_filename_to_slot (const char *dirname,
 		}
 	      
 	      dirs[files[num].dir] = xmemdup0 (dirname, strlen (dirname));
+	      if (dirs_in_use <= files[num].dir)
+		dirs_in_use = files[num].dir + 1;
 	    }
 	    
 	  return true;
@@ -911,6 +913,8 @@ allocate_filename_to_slot (const char *dirname,
 		    }
 
 		  dirs[files[num].dir] = xmemdup0 (filename, file - filename);
+		  if (dirs_in_use <= files[num].dir)
+		    dirs_in_use = files[num].dir + 1;
 		}
 	      return true;
 	    }


More information about the Binutils-cvs mailing list