From 91e72409bec0910456e1c34457a04ca00e2f7b99 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Tue, 25 Jul 2017 10:42:01 +0200 Subject: [PATCH] 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 Signed-off-by: Cyrill Gorcunov Signed-off-by: H. Peter Anvin --- asm/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/asm/preproc.c +++ b/asm/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);