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:34:05 +0400
commit7d96ac6a567df5075e3f4f4019d6d24727db8361 (patch)
treecdc2011728225880d016ae04ca937ed95e6cd62c
parenta947529954d9db0214e65d2c856111f823381f7c (diff)
downloadnasm-7d96ac6a567df5075e3f4f4019d6d24727db8361.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. [mainstream adabc1576b957fc7d929d2c7e749b4f45f7293aa] 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 1af58d92..3c358284 100644
--- a/preproc.c
+++ b/preproc.c
@@ -3594,7 +3594,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;
}
}