Check asprintf return value
[deliverable/binutils-gdb.git] / bfd / elf32-nios2.c
index b0f200d0f8efdbd54ce96e06d37c328d20af16b5..5d787eb2f4010692fe23121eb8f73e6d60cd8278 100644 (file)
@@ -3821,7 +3821,9 @@ nios2_elf32_relocate_section (bfd *output_bfd,
 
                  format = _("global pointer relative relocation at address "
                             "%#" PRIx64 " when _gp not defined\n");
-                 asprintf (&msgbuf, format, (uint64_t) reloc_address);
+                 if (asprintf (&msgbuf, format,
+                               (uint64_t) reloc_address) == -1)
+                   msgbuf = NULL;
                  msg = msgbuf;
                  r = bfd_reloc_dangerous;
                }
@@ -3851,9 +3853,10 @@ nios2_elf32_relocate_section (bfd *output_bfd,
                                 "the global pointer (at %#" PRIx64 ") "
                                 "because the offset (%" PRId64 ") is out of "
                                 "the allowed range, -32678 to 32767\n" );
-                     asprintf (&msgbuf, format, name,
-                               (uint64_t) symbol_address, (uint64_t) gp,
-                               (int64_t) relocation);
+                     if (asprintf (&msgbuf, format, name,
+                                   (uint64_t) symbol_address, (uint64_t) gp,
+                                   (int64_t) relocation) == -1)
+                       msgbuf = NULL;
                      msg = msgbuf;
                      r = bfd_reloc_outofrange;
                    }
This page took 0.033415 seconds and 4 git commands to generate.