From 52e389ba0d1de9131f6be288cfaf9b28a0b732e5 Mon Sep 17 00:00:00 2001 From: stefan Date: Mon, 1 Aug 2016 16:40:09 +0000 Subject: [PATCH] Make sure variables are initialized before using them In elf.c, do not increment `s' before it is initialized. At the time of the increment, `s' is otherwise unused anyway. In elflink.c, initialize sec_contents and l_sec_contents to make sure that the free(sec_contents) and free(l_sec_contents) are called on valid pointers. ok jca@ guenther@ --- gnu/usr.bin/binutils-2.17/bfd/elf.c | 2 +- gnu/usr.bin/binutils-2.17/bfd/elflink.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf.c b/gnu/usr.bin/binutils-2.17/bfd/elf.c index 2e874b8d166..c74b8503da9 100644 --- a/gnu/usr.bin/binutils-2.17/bfd/elf.c +++ b/gnu/usr.bin/binutils-2.17/bfd/elf.c @@ -8617,7 +8617,7 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd, count = relplt->size / hdr->sh_entsize; size = count * sizeof (asymbol); p = relplt->relocation; - for (i = 0; i < count; i++, s++, p++) + for (i = 0; i < count; i++, p++) size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); s = *ret = bfd_malloc (size); diff --git a/gnu/usr.bin/binutils-2.17/bfd/elflink.c b/gnu/usr.bin/binutils-2.17/bfd/elflink.c index baa6e590148..2673b408a18 100644 --- a/gnu/usr.bin/binutils-2.17/bfd/elflink.c +++ b/gnu/usr.bin/binutils-2.17/bfd/elflink.c @@ -9862,7 +9862,7 @@ _bfd_elf_section_already_linked (bfd *abfd, struct bfd_section *sec, abfd, sec); else if (sec->size != 0) { - bfd_byte *sec_contents, *l_sec_contents; + bfd_byte *sec_contents = NULL, *l_sec_contents = NULL; if (!bfd_malloc_and_get_section (abfd, sec, &sec_contents)) (*_bfd_error_handler) -- 2.20.1