summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2010-07-10 02:11:41 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2010-07-10 02:14:24 +0400
commitadabc1576b957fc7d929d2c7e749b4f45f7293aa (patch)
tree748d3c4559350440cc2a1e6124def81e8de6e422
parent8ab945a259e40c2e4dc92e91f8fc78bf7c2e2175 (diff)
downloadnasm-adabc1576b957fc7d929d2c7e749b4f45f7293aa.tar.gz
preproc.c: Fix NULL deref on token pasting
In case if there is a whitespace before 'paste' token we may reach NULL dereference in strlen since paste_head will point to TOK_WHITESPACE. Fix it. [test: paste.asm] Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--preproc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/preproc.c b/preproc.c
index f82ac44a..24fb7947 100644
--- a/preproc.c
+++ b/preproc.c
@@ -3586,7 +3586,9 @@ static bool paste_tokens(Token **head, bool handle_paste_tokens)
}
/* else fall through */
default:
- tail = paste_head = &t->next;
+ tail = &t->next;
+ if (!tok_type_(t->next, TOK_WHITESPACE))
+ paste_head = tail;
break;
}
}