aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-avr.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2018-08-01 14:42:37 +0100
committerNick Clifton <nickc@redhat.com>2018-08-01 14:42:37 +0100
commit4a9f7d653c089fdd8ca66a51caab7c9687f50cd1 (patch)
treefc13e5d5ada78b65df208b7ab73aee190b6d82e4 /bfd/elf32-avr.c
parentf03fb29221a00c294e14850f1fa1af343cded926 (diff)
downloadgdb-4a9f7d653c089fdd8ca66a51caab7c9687f50cd1.zip
gdb-4a9f7d653c089fdd8ca66a51caab7c9687f50cd1.tar.gz
gdb-4a9f7d653c089fdd8ca66a51caab7c9687f50cd1.tar.bz2
Fix potential illegal memory access in AVR backend.
* elf32-avr.c (avr_stub_name): Check for a NULL return from bfd_malloc.
Diffstat (limited to 'bfd/elf32-avr.c')
-rw-r--r--bfd/elf32-avr.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 7087606..6d38d1d 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;
}