From 0e8efb23bec14057b21ff7aab280e5a82e1bde30 Mon Sep 17 00:00:00 2001 From: Adam Majer <amajer@suse.de> Date: Tue, 25 Jul 2017 11:12:35 +0200 Subject: [PATCH 1/3] preproc: Only concat tok->text if we accounted for its size https://bugzilla.nasm.us/show_bug.cgi?id=3392415 Signed-off-by: Adam Majer <amajer@suse.de> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> --- preproc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/asm/preproc.c b/asm/preproc.c index 97e87d2c..22c90f2b 100644 --- a/preproc.c +++ b/preproc.c @@ -3845,9 +3845,15 @@ static bool paste_tokens(Token **head, const struct tokseq_match *m, len += strlen(tok->text); p = buf = nasm_malloc(len + 1); + strcpy(p, tok->text); + p = strchr(p, '\0'); + tok = delete_Token(tok); + while (tok != next) { - strcpy(p, tok->text); - p = strchr(p, '\0'); + if (PP_CONCAT_MATCH(tok, m[i].mask_tail)) { + strcpy(p, tok->text); + p = strchr(p, '\0'); + } tok = delete_Token(tok); } -- 2.13.3