sect = bfd_get_section_by_name (abfd, GNU_DEBUGLINK);
- if (sect == NULL)
+ if (sect == NULL || (sect->flags & SEC_HAS_CONTENTS) == 0)
return NULL;
size = bfd_section_size (sect);
return NULL;
if (!bfd_malloc_and_get_section (abfd, sect, &contents))
- {
- free (contents);
- return NULL;
- }
+ return NULL;
/* CRC value is stored after the filename, aligned up to 4 bytes. */
name = (char *) contents;
crc_offset = strnlen (name, size) + 1;
crc_offset = (crc_offset + 3) & ~3;
if (crc_offset + 4 > size)
- return NULL;
+ {
+ free (name);
+ return NULL;
+ }
*crc32 = bfd_get_32 (abfd, contents + crc_offset);
return name;
sect = bfd_get_section_by_name (abfd, GNU_DEBUGALTLINK);
- if (sect == NULL)
+ if (sect == NULL || (sect->flags & SEC_HAS_CONTENTS) == 0)
return NULL;
size = bfd_section_size (sect);
return NULL;
if (!bfd_malloc_and_get_section (abfd, sect, & contents))
- {
- free (contents);
- return NULL;
- }
+ return NULL;
/* BuildID value is stored after the filename. */
name = (char *) contents;
return (struct bfd_build_id *) abfd->build_id;
sect = bfd_get_section_by_name (abfd, ".note.gnu.build-id");
- if (sect == NULL)
+ if (sect == NULL
+ || (sect->flags & SEC_HAS_CONTENTS) == 0)
{
bfd_set_error (bfd_error_no_debug_section);
return NULL;
}
if (!bfd_malloc_and_get_section (abfd, sect, & contents))
- {
- free (contents);
- return NULL;
- }
+ return NULL;
/* FIXME: Paranoia - allow for compressed build-id sections.
Maybe we should complain if this size is different from