preproc: reserve space for terminal NUL in %strcat

Technically, this is not necessary, because make_tok_qstr_len()
doesn't rely on NUL termination, and in fact it *can't*, since the
string might contain embedded NULs, but tacking on a NUL is good for
debugging if nothing else. That means reserving space for it!

Reported-by: C. Masloch <pushbx@ulukai.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2019-10-17 18:22:43 -07:00
parent 18f4134222
commit f770ce8be4

View File

@ -4234,7 +4234,7 @@ issue_error:
}
}
q = qbuf = nasm_malloc(len);
q = qbuf = nasm_malloc(len+1);
list_for_each(t, tline) {
if (t->type == TOK_INTERNAL_STRING)
q = mempcpy(q, tok_text(t), t->len);