diff --git a/asm/preproc.c b/asm/preproc.c index 14a73885..647e537c 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -612,6 +612,7 @@ static Token *expand_smacro(Token * tline); static Token *expand_id(Token * tline); static Context *get_ctx(const char *name, const char **namep); static Token *make_tok_num(Token *next, int64_t val); +static Token *make_tok_qstr_with_len(Token *next, const char *str, size_t len); static Token *make_tok_qstr(Token *next, const char *str); static Token *make_tok_char(Token *next, char op); static Token *new_Token(Token * next, enum pp_token_type type, @@ -4236,7 +4237,7 @@ issue_error: * zero, and a numeric token to use as an expansion. Create * and store an SMacro. */ - macro_start = make_tok_qstr(NULL, qbuf); + macro_start = make_tok_qstr_with_len(NULL, qbuf, len); nasm_free(qbuf); define_smacro(mname, casesense, macro_start, NULL); free_tlist(tline); @@ -4313,7 +4314,7 @@ issue_error: txt = (start < 0) ? "" : tok_text(t) + start; len = count; - macro_start = make_tok_qstr(NULL, txt); + macro_start = make_tok_qstr_with_len(NULL, txt, len); /* * We now have a macro name, an implicit parameter count of @@ -6563,13 +6564,18 @@ static Token *make_tok_num(Token *next, int64_t val) } /* Create a quoted string token */ -static Token *make_tok_qstr(Token *next, const char *str) +static Token *make_tok_qstr_with_len(Token *next, const char *str, size_t len) { - size_t len = strlen(str); char *p = nasm_quote(str, &len); return new_Token_free(next, TOK_STRING, p, len); } +static Token *make_tok_qstr(Token *next, const char *str) +{ + size_t len = strlen(str); + return make_tok_qstr_with_len(next, str, len); +} + /* Create a single-character operator token */ static Token *make_tok_char(Token *next, char op) {