preproc.: Fix NULL dereference on broken %strlen argument

Under particular circumstances %strlen may cause SIGSEG. A typical
example is %strlen with nonexistent macro argument.

[ Testcase test/strlen.asm ]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2010-07-23 18:51:51 +04:00
parent 077fb93d2b
commit 4e1d5ab0cf
2 changed files with 6 additions and 1 deletions

View File

@ -3254,7 +3254,7 @@ issue_error:
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,
"`%%strlen` requires string as second parameter");
free_tlist(tline);

5
test/strlen.asm Normal file
View File

@ -0,0 +1,5 @@
%macro strlen_test 1
%strlen len %2 ; not existing argument
%endmacro
strlen_test 'a'