This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Commit: AVR: Check for a NULL pointer before creating a stub name
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Wed, 01 Aug 2018 14:42:20 +0100
- Subject: Commit: AVR: Check for a NULL pointer before creating a stub name
Hi Guys,
I am checking in the patch below to fix a potential illegal memory
access in the AVR code, should bfd_malloc() return NULL.
Cheers
Nick
bfd/ChangeLog
2018-08-01 Nick Clifton <nickc@redhat.com>
* elf32-avr.c (avr_stub_name): Check for a NULL return from
bfd_malloc.
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 7087606c93..6d38d1db3a 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -3295,10 +3295,10 @@ avr_stub_name (const asection *symbol_section,
len = 8 + 1 + 8 + 1 + 1;
stub_name = bfd_malloc (len);
-
- sprintf (stub_name, "%08x+%08x",
- symbol_section->id & 0xffffffff,
- (unsigned int) ((rela->r_addend & 0xffffffff) + symbol_offset));
+ if (stub_name != NULL)
+ sprintf (stub_name, "%08x+%08x",
+ symbol_section->id & 0xffffffff,
+ (unsigned int) ((rela->r_addend & 0xffffffff) + symbol_offset));
return stub_name;
}