diff options
author | Alan Modra <amodra@gmail.com> | 2022-12-12 19:01:08 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-12-12 19:25:19 +1030 |
commit | 65cf035b8dc1df5d8020e0b1449514a3c42933e7 (patch) | |
tree | 2fe2617314913feb52070ca2c4aeb0bf1bdc71cf /bfd | |
parent | 77c225bdeb410cf60da804879ad41622f5f1aa44 (diff) | |
download | binutils-65cf035b8dc1df5d8020e0b1449514a3c42933e7.zip binutils-65cf035b8dc1df5d8020e0b1449514a3c42933e7.tar.gz binutils-65cf035b8dc1df5d8020e0b1449514a3c42933e7.tar.bz2 |
PR29892, Field file_table of struct module is uninitialized
PR 29892
* vms-alphs.c (new_module): Use bfd_zmalloc to alloc file_table.
(parse_module): Rewrite file_table reallocation code and clear.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/vms-alpha.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 3b63259..6ee7060 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -4337,7 +4337,7 @@ new_module (bfd *abfd) = (struct module *) bfd_zalloc (abfd, sizeof (struct module)); module->file_table_count = 16; /* Arbitrary. */ module->file_table - = bfd_malloc (module->file_table_count * sizeof (struct fileinfo)); + = bfd_zmalloc (module->file_table_count * sizeof (struct fileinfo)); return module; } @@ -4520,15 +4520,18 @@ parse_module (bfd *abfd, struct module *module, unsigned char *ptr, src_ptr + DST_S_B_SRC_DF_FILENAME, ptr + rec_length - (src_ptr + DST_S_B_SRC_DF_FILENAME)); - while (fileid >= module->file_table_count) + if (fileid >= module->file_table_count) { - module->file_table_count *= 2; + unsigned int old_count = module->file_table_count; + module->file_table_count += fileid; module->file_table = bfd_realloc_or_free (module->file_table, module->file_table_count * sizeof (struct fileinfo)); if (module->file_table == NULL) return false; + memset (module->file_table + old_count, 0, + fileid * sizeof (struct fileinfo)); } module->file_table [fileid].name = filename; |