memory leak in gas dwarf2dbg.c

Message ID Z3U3TlzRUY1PsFjW@squeak.grove.modra.org
State New
Headers
Series memory leak in gas dwarf2dbg.c |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Alan Modra Jan. 1, 2025, 12:38 p.m. UTC
  Found when running the pr27355 testcase.

	PR 27355
	PR 27426
	* dwarf2dbg.c (allocate_filename_to_slot): Update dirs_in_use.
  

Patch

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;
 	    }