]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
PR25651, objcopy SIGSEGV in copy_object
authorAlan Modra <amodra@gmail.com>
Wed, 11 Mar 2020 03:20:35 +0000 (13:50 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 11 Mar 2020 04:31:15 +0000 (15:01 +1030)
commit9cc89dc0acc140cb27e21d2597af42d36444673b
tree6fc9a4fe2c099ba2fa0714c2b7933cf827833ae6
parent1db6f990303ab6c45909f8e133641ef6c24a04d2
PR25651, objcopy SIGSEGV in copy_object

With the right set of options, the second block of code dealing with
padding can see a different section count.  So don't use the new count.
Since I was editing those lines, I've also changed the code allocating
arrays a little.
    array = malloc (n * sizeof (*array));
for an array of ints is just better than
    array = malloc (n * sizeof (int));
It's easier to write correctly in the first place and more robust
against code changes that might modify the array element type.

PR 25651
* objcopy.c (copy_object): Test "gaps" not gap_fill_set or
pad_to_set on second block of code dealing with padding.
Replace "c" with "num_sec" and don't recalculate number of
sections on second block.  Size arrays using sizeof (element)
rather than sizeof (element type).
binutils/ChangeLog
binutils/objcopy.c