PR27426, More bugs in dwarf2dbg.c
authorAlan Modra <amodra@gmail.com>
Tue, 16 Feb 2021 04:09:04 +0000 (14:39 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 16 Feb 2021 04:17:41 +0000 (14:47 +1030)
PR 27426
* dwarf2dbg.c (allocate_filename_to_slot): Allocate the dirs array
in another place.

gas/ChangeLog
gas/dwarf2dbg.c

index f4c9d0a0fa60f67e2e75157b711621039b1bdf6a..c74e63cd13520d97ee051970c0af9071b1561c58 100644 (file)
@@ -1,3 +1,9 @@
+2021-02-16  Alan Modra  <amodra@gmail.com>
+
+       PR 27426
+       * dwarf2dbg.c (allocate_filename_to_slot): Allocate the dirs array
+       in another place.
+
 2021-02-16  Alan Modra  <amodra@gmail.com>
 
        * read.c (demand_copy_C_string): Really check for embedded zeros.
index f0cdc232f53cf411964fa1ab91c858c88f45de09..85db0bef230a13125ed75d1567ba706fa1bd3df0 100644 (file)
@@ -812,10 +812,18 @@ allocate_filename_to_slot (const char *  dirname,
          file = get_basename (filename);
          if (filename_cmp (file, files[num].filename) == 0)
            {
+             /* The filenames match, but the directory table entry is empty.
+                Fill it with the provided directory name.  */
              if (file > filename)
-               /* The filenames match, but the directory table entry is empty.
-                  Fill it with the provided directory name.  */
-               dirs[files[num].dir] = xmemdup0 (filename, file - filename);
+               {
+                 if (dirs == NULL)
+                   {
+                     dirs_allocated = files[num].dir + 32;
+                     dirs = XCNEWVEC (char *, dirs_allocated);
+                   }
+
+                 dirs[files[num].dir] = xmemdup0 (filename, file - filename);
+               }
              return TRUE;
            }
        }