Fix potential illegal memory access in AVR backend.
authorNick Clifton <nickc@redhat.com>
Wed, 1 Aug 2018 13:42:37 +0000 (14:42 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 1 Aug 2018 13:42:37 +0000 (14:42 +0100)
* elf32-avr.c (avr_stub_name): Check for a NULL return from
bfd_malloc.

bfd/ChangeLog
bfd/elf32-avr.c

index 117a8db..59b7266 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-01  Nick Clifton  <nickc@redhat.com>
+
+       * elf32-avr.c (avr_stub_name): Check for a NULL return from
+       bfd_malloc.
+
 2018-08-01  Zenith  <zenith432@users.sourceforge.net>
 
        PR 23460
index 7087606..6d38d1d 100644 (file)
@@ -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;
 }