Tidy elf_segment_map allocation
[deliverable/binutils-gdb.git] / bfd / dwarf2.c
index ca22db766c54a0ee8c35199b5110b03d9f7524d8..3a786fb839f5beb3cf01ab2ef141224e718904ab 100644 (file)
@@ -345,7 +345,7 @@ const struct dwarf_debug_section dwarf_debug_sections[] =
   { NULL,                      NULL },
 };
 
-/* NB/ Numbers in this enum must match up with indicies
+/* NB/ Numbers in this enum must match up with indices
    into the dwarf_debug_sections[] array above.  */
 enum dwarf_debug_section_enum
 {
@@ -527,6 +527,7 @@ read_section (bfd *       abfd,
   asection *msec;
   const char *section_name = sec->uncompressed_name;
   bfd_byte *contents = *section_buffer;
+  bfd_size_type amt;
 
   /* The section may have already been read.  */
   if (contents == NULL)
@@ -549,7 +550,13 @@ read_section (bfd *              abfd,
       *section_size = msec->rawsize ? msec->rawsize : msec->size;
       /* Paranoia - alloc one extra so that we can make sure a string
         section is NUL terminated.  */
-      contents = (bfd_byte *) bfd_malloc (*section_size + 1);
+      amt = *section_size + 1;
+      if (amt == 0)
+       {
+         bfd_set_error (bfd_error_no_memory);
+         return FALSE;
+       }
+      contents = (bfd_byte *) bfd_malloc (amt);
       if (contents == NULL)
        return FALSE;
       if (syms
@@ -1566,7 +1573,7 @@ concat_filename (struct line_info_table *table, unsigned int file)
 {
   char *filename;
 
-  if (file - 1 >= table->num_files)
+  if (table == NULL || file - 1 >= table->num_files)
     {
       /* FILE == 0 means unknown.  */
       if (file)
@@ -2837,7 +2844,9 @@ find_abstract_instance (struct comp_unit *   unit,
       info_ptr = unit->stash->info_ptr_memory;
       info_ptr_end = unit->stash->info_ptr_end;
       total = info_ptr_end - info_ptr;
-      if (!die_ref || die_ref >= total)
+      if (!die_ref)
+       return TRUE;
+      else if (die_ref >= total)
        {
          _bfd_error_handler
            (_("DWARF error: invalid abstract instance DIE ref"));
@@ -2953,7 +2962,7 @@ find_abstract_instance (struct comp_unit *   unit,
                  break;
                case DW_AT_specification:
                  if (!find_abstract_instance (unit, info_ptr, &attr,
-                                              pname, is_linkage,
+                                              &name, is_linkage,
                                               filename_ptr, linenumber_ptr))
                    return FALSE;
                  break;
This page took 0.023727 seconds and 4 git commands to generate.