preproc: Fix out of bound access on malformed input

A fuzzer revealed a problem in preproc code.

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

Reported-by: ganshuitao <ganshuitao@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2018-10-28 20:39:34 +03:00
parent fe2e1d469a
commit 661f723d39

View File

@ -4002,7 +4002,7 @@ static Token *expand_mmac_params(Token * tline)
thead = NULL;
while (tline) {
if (tline->type == TOK_PREPROC_ID &&
if (tline->type == TOK_PREPROC_ID && tline->text && tline->text[0] &&
(((tline->text[1] == '+' || tline->text[1] == '-') && tline->text[2]) ||
(tline->text[1] >= '0' && tline->text[1] <= '9') ||
tline->text[1] == '%')) {