if (to_read > PRIV (recrd.buf_size))
{
PRIV (recrd.buf)
- = (unsigned char *) bfd_realloc (PRIV (recrd.buf), to_read);
+ = (unsigned char *) bfd_realloc_or_free (PRIV (recrd.buf), to_read);
if (PRIV (recrd.buf) == NULL)
return 0;
PRIV (recrd.buf_size) = to_read;
else
{
PRIV (max_sym_count) *= 2;
- PRIV (syms) = bfd_realloc
+ PRIV (syms) = bfd_realloc_or_free
(PRIV (syms),
(PRIV (max_sym_count) * sizeof (struct vms_symbol_entry *)));
}
/* Save current DST location counter under specified index. */
-static void
+static bfd_boolean
dst_define_location (bfd *abfd, unsigned int loc)
{
vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc));
/* Grow the ptr offset table if necessary. */
if (loc + 1 > PRIV (dst_ptr_offsets_count))
{
- PRIV (dst_ptr_offsets) = bfd_realloc (PRIV (dst_ptr_offsets),
- (loc + 1) * sizeof (unsigned int));
+ PRIV (dst_ptr_offsets)
+ = bfd_realloc_or_free (PRIV (dst_ptr_offsets),
+ (loc + 1) * sizeof (unsigned int));
+ if (PRIV (dst_ptr_offsets) == NULL)
+ return FALSE;
PRIV (dst_ptr_offsets_count) = loc + 1;
}
PRIV (dst_ptr_offsets)[loc] = PRIV (image_offset);
+ return TRUE;
}
/* Restore saved DST location counter from specified index. */
return FALSE;
if (rel1 != RELC_NONE)
goto bad_context;
- dst_define_location (abfd, op1);
+ if (!dst_define_location (abfd, op1))
+ return FALSE;
break;
/* Set location: pop index, restore location counter from index
bfd_set_error (bfd_error_file_too_big);
return NULL;
}
- vec->els = bfd_realloc (vec->els, amt);
+ vec->els = bfd_realloc_or_free (vec->els, amt);
}
}
if (vec->els == NULL)
/* Parse debug info for a module and internalize it. */
-static void
+static bfd_boolean
parse_module (bfd *abfd, struct module *module, unsigned char *ptr,
int length)
{
{
module->file_table_count *= 2;
module->file_table
- = bfd_realloc (module->file_table,
- module->file_table_count
- * sizeof (struct fileinfo));
+ = bfd_realloc_or_free (module->file_table,
+ module->file_table_count
+ * sizeof (struct fileinfo));
+ if (module->file_table == NULL)
+ return FALSE;
}
module->file_table [fileid].name = filename;
because parsing can be either performed at module creation
or deferred until debug info is consumed. */
SET_MODULE_PARSED (module);
+ return TRUE;
}
/* Build the list of modules for the specified BFD. */
return NULL;
module = new_module (abfd);
- parse_module (abfd, module, PRIV (dst_section)->contents, -1);
+ if (!parse_module (abfd, module, PRIV (dst_section)->contents, -1))
+ return NULL;
list = module;
}
return FALSE;
}
- parse_module (abfd, module, buffer, size);
+ ret = parse_module (abfd, module, buffer, size);
free (buffer);
+ if (!ret)
+ return ret;
}
/* Find out the function (if any) that contains the address. */
else
{
vms_sec->reloc_max *= 2;
- sec->relocation = bfd_realloc
+ sec->relocation = bfd_realloc_or_free
(sec->relocation, vms_sec->reloc_max * sizeof (arelent));
+ if (sec->relocation == NULL)
+ return FALSE;
}
}
reloc = &sec->relocation[sec->reloc_count];