Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > fdaafdad8ba2c9963d0569ec5db69f76 > files > 2

nasm-2.12.02-1.1.mga6.src.rpm

From 35c32162338847b935bc4d2cab7378caeb48e2ca Mon Sep 17 00:00:00 2001
From: Adam Majer <amajer@suse.de>
Date: Tue, 25 Jul 2017 10:42:01 +0200
Subject: [PATCH 2/3] preproc: Workaround a usage after free bug

In some circumstantes this free is incorrect resulting
in usage after-free. Workaround it by not freeing memory
here.

https://bugzilla.nasm.us/show_bug.cgi?id=3392414

gorcunov@:
 - slightly tuneup the comment

Signed-off-by: Adam Majer <amajer@suse.de>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 preproc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/asm/preproc.c b/asm/preproc.c
index 22c90f2b..f6e296b4 100644
--- a/preproc.c
+++ b/preproc.c
@@ -5101,8 +5101,18 @@ static char *pp_getline(void)
                             nasm_free(m->paramlen);
                             l->finishes->in_progress = 0;
                         }
-                    } else
+                    }
+
+                    /*
+                     * FIXME It is incorrect to always free_mmacro here.
+                     * It leads to usage-after-free.
+                     *
+                     * https://bugzilla.nasm.us/show_bug.cgi?id=3392414
+                     */
+#if 0
+                    else
                         free_mmacro(m);
+#endif
                 }
                 istk->expansion = l->next;
                 nasm_free(l);
-- 
2.13.3