Fix an illegal memory access when parsing a corrupt assembler file.
authorNick Clifton <nickc@redhat.com>
Mon, 8 Feb 2021 18:31:21 +0000 (18:31 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 8 Feb 2021 18:31:21 +0000 (18:31 +0000)
PR 27355
* dwarf2dbg.c (allocate_filename_to_slot): Allocate the dirs array
if it has not already been created.

gas/ChangeLog
gas/dwarf2dbg.c

index 3d55c7f36cc98bf2471574777ca87dc2ea0c0099..83b2721c293b62de1958b093b9447734569d9386 100644 (file)
@@ -1,3 +1,9 @@
+2021-02-08  Nick Clifton  <nickc@redhat.com>
+
+       PR 27355
+       * dwarf2dbg.c (allocate_filename_to_slot): Allocate the dirs array
+       if it has not already been created.
+
 2021-02-04  Nelson Chu  <nelson.chu@sifive.com>
 
        * config/tc-riscv.c (riscv_multi_subset_supports): Removed
index 4fbd1e38ec22cbc5f584d155fbe5fde04e306f24..f0cdc232f53cf411964fa1ab91c858c88f45de09 100644 (file)
@@ -769,7 +769,7 @@ allocate_filename_to_slot (const char *  dirname,
     {
       const char * dir = NULL;
 
-      if (dirs)
+      if (dirs != NULL)
        dir = dirs[files[num].dir];
 
       if (with_md5
@@ -787,7 +787,15 @@ allocate_filename_to_slot (const char *  dirname,
          /* If the filenames match, but the directory table entry was
             empty, then fill it with the provided directory name.  */
          if (dir == NULL)
-           dirs[files[num].dir] = xmemdup0 (dirname, strlen (dirname));
+           {
+             if (dirs == NULL)
+               {
+                 dirs_allocated = files[num].dir + 32;
+                 dirs = XCNEWVEC (char *, dirs_allocated);
+               }
+             
+             dirs[files[num].dir] = xmemdup0 (dirname, strlen (dirname));
+           }
            
          return TRUE;
        }