PR27426, More bugs in dwarf2dbg.c

PR 27426
	* dwarf2dbg.c (allocate_filename_to_slot): Allocate the dirs array
	in another place.
This commit is contained in:
Alan Modra 2021-02-16 14:39:04 +10:30
parent 7043388668
commit 9a12b194b0
2 changed files with 17 additions and 3 deletions

View 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.

View File

@ -812,10 +812,18 @@ allocate_filename_to_slot (const char * dirname,
file = get_basename (filename);
if (filename_cmp (file, files[num].filename) == 0)
{
if (file > filename)
/* The filenames match, but the directory table entry is empty.
Fill it with the provided directory name. */
if (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;
}
}