peXXigen.c sanity checks
authorAlan Modra <amodra@gmail.com>
Sat, 7 Jan 2023 01:20:10 +0000 (11:50 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 9 Jan 2023 23:38:52 +0000 (10:08 +1030)
commit10c386190cb8dcc398292b6053d5fbf6bfd3a4ff
tree58f697d4c006b5de32e266309fa0c45f9782f69d
parent5a671d7a854b4e4cf31837e423419654139a482d
peXXigen.c sanity checks

Also fix a memory leak, and make some style changes.  I tend to read
(sizeof * x) as a multiplication of two variables, which I would not
do if binutils followed the gcc coding conventions consistently (see
https://gcc.gnu.org/codingconventions.html#Expressions).  (sizeof *x)
looks a lot better to me, or even (sizeof (*x)) which I've used here.

* peXXigen.c (get_contents_sanity_check): New function.
(pe_print_idata): Use it here..
(pe_print_edata): ..and here.  Free data on error return.
(rsrc_parse_entry): Check entry size read from file.
(rsrc_parse_entries): Style fixes.
(rsrc_process_section): Use bfd_malloc_and_get_section.
(_bfd_XXi_final_link_postscript): Likewise.
bfd/peXXigen.c