[nasm:master] BR3392739: output/outbin: fix nil dereference for self following sections

nasm-bot for Cyrill Gorcunov gorcunov at gmail.com
Sat Feb 20 14:12:16 PST 2021


Commit-ID:  8c735c58d191c217d75a8137a850ffc56cd4a269
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=8c735c58d191c217d75a8137a850ffc56cd4a269
Author:     Cyrill Gorcunov <gorcunov at gmail.com>
AuthorDate: Sun, 21 Feb 2021 01:05:28 +0300
Committer:  Cyrill Gorcunov <gorcunov at gmail.com>
CommitDate: Sun, 21 Feb 2021 01:05:28 +0300

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 at gmail.com>


---
 output/outbin.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/output/outbin.c b/output/outbin.c
index 3e09005e..2ceec7d1 100644
--- a/output/outbin.c
+++ b/output/outbin.c
@@ -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"


More information about the Nasm-commits mailing list