summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2010-09-06 23:49:52 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2010-09-07 00:10:23 +0400
commit49cd6fbccf0414950b03555bb2efbb0c4dc163c0 (patch)
treeb3bf98b38f164e60648c922e28966ac820a6feae
parente12c50d274198fdc6a60429a193eef95be391173 (diff)
downloadnasm-49cd6fbccf0414950b03555bb2efbb0c4dc163c0.tar.gz
Fix NULL dereferences on %substr missing operands
%substr with dangling id issues SIGSEV. Fix it. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--preproc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/preproc.c b/preproc.c
index e3b0c640..22d30ca9 100644
--- a/preproc.c
+++ b/preproc.c
@@ -3395,12 +3395,13 @@ issue_error:
tline = expand_smacro(tline->next);
last->next = NULL;
- t = tline->next;
+ if (tline) /* skip expanded id */
+ t = tline->next;
while (tok_type_(t, TOK_WHITESPACE))
t = t->next;
/* t should now point to the string */
- if (t->type != TOK_STRING) {
+ if (!tok_type_(t, TOK_STRING)) {
error(ERR_NONFATAL,
"`%%substr` requires string as second parameter");
free_tlist(tline);