[nasm:master] BR3392637: output/outieee: Fix nil dereference

nasm-bot for Cyrill Gorcunov gorcunov at gmail.com
Wed Nov 4 02:18:10 PST 2020


Commit-ID:  93c774d482694643cafbc82578ac8b729fb5bc8b
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=93c774d482694643cafbc82578ac8b729fb5bc8b
Author:     Cyrill Gorcunov <gorcunov at gmail.com>
AuthorDate: Wed, 4 Nov 2020 13:08:06 +0300
Committer:  Cyrill Gorcunov <gorcunov at gmail.com>
CommitDate: Wed, 4 Nov 2020 13:08:06 +0300

BR3392637: output/outieee: Fix nil dereference

The handling been broken in commit 98578071.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>


---
 output/outieee.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/output/outieee.c b/output/outieee.c
index bff2f085..b3ccc5f6 100644
--- a/output/outieee.c
+++ b/output/outieee.c
@@ -795,6 +795,23 @@ static int32_t ieee_segment(char *name, int *bits)
             define_label(name, seg->index + 1, 0L, false);
         ieee_seg_needs_update = NULL;
 
+        /*
+         * In commit 98578071b9d71ecaa2344dd9c185237c1765041e
+         * we reworked labels significantly which in turn lead
+         * to the case where seg->name = NULL here and we get
+         * nil dereference in next segments definitions.
+         *
+         * Lets placate this case with explicit name setting
+         * if labels engine didn't set it yet.
+         *
+         * FIXME: Need to revisit this moment if such fix doesn't
+         * break anything but since IEEE 695 format is veeery
+         * old I don't expect there are many users left. In worst
+         * case this should only lead to a memory leak.
+         */
+        if (!seg->name)
+            seg->name = nasm_strdup(name);
+
         if (seg->use32)
             *bits = 32;
         else


More information about the Nasm-commits mailing list