BR3392739: output/outbin: fix nil dereference for self following sections

In case if section follows itself we should yield
an error, otherwise we hit nil dereference because
there won't be any group of sections.

After all "follow" attribute is rather to group
sections other than self.



Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2021-02-21 01:05:28 +03:00
parent 79ac0d686d
commit 8c735c58d1

View file

@ -335,6 +335,8 @@ static void bin_cleanup(void)
if (!s)
nasm_fatal("section %s follows an invalid or"
" unknown section (%s)", g->name, g->follows);
if (s == g)
nasm_fatal("section %s is self following", s->name);
if (s->next && (s->next->flags & FOLLOWS_DEFINED) &&
!strcmp(s->name, s->next->follows))
nasm_fatal("sections %s and %s can't both follow"