From: Alan Modra Date: Tue, 16 Feb 2021 04:09:04 +0000 (+1030) Subject: PR27426, More bugs in dwarf2dbg.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9a12b194b0e9d1bde34aca175a2a7dead2fae7a9;p=binutils-gdb.git PR27426, More bugs in dwarf2dbg.c PR 27426 * dwarf2dbg.c (allocate_filename_to_slot): Allocate the dirs array in another place. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index f4c9d0a0fa6..c74e63cd135 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2021-02-16 Alan Modra + + PR 27426 + * dwarf2dbg.c (allocate_filename_to_slot): Allocate the dirs array + in another place. + 2021-02-16 Alan Modra * read.c (demand_copy_C_string): Really check for embedded zeros. diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index f0cdc232f53..85db0bef230 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -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; } }