if (stash->sec_vma == NULL)
return FALSE;
stash->sec_vma_count = abfd->section_count;
- for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next)
+ for (i = 0, s = abfd->sections;
+ s != NULL && i < abfd->section_count;
+ i++, s = s->next)
{
if (s->output_section != NULL)
stash->sec_vma[i] = s->output_section->vma + s->output_offset;
if (abfd->section_count != stash->sec_vma_count)
return FALSE;
- for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next)
+ for (i = 0, s = abfd->sections;
+ s != NULL && i < abfd->section_count;
+ i++, s = s->next)
{
bfd_vma vma;