diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-06-04 11:26:59 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-06-04 11:26:59 -0700 |
commit | 88c9e1f88cd1e67ad4fb2834f3cad6160d5a3fbb (patch) | |
tree | 01b0135d5f68e2e9cb80ccdf774d9f687c33fda2 /stdscan.c | |
parent | 0eebf799db452dc1980931bd2f15efde5ecdf28c (diff) | |
download | nasm-88c9e1f88cd1e67ad4fb2834f3cad6160d5a3fbb.tar.gz nasm-88c9e1f88cd1e67ad4fb2834f3cad6160d5a3fbb.tar.bz2 nasm-88c9e1f88cd1e67ad4fb2834f3cad6160d5a3fbb.zip |
Fix memory management issues with expanded %include
Ownership of the filename string was a bit fuzzy, with the result that
we were freeing it even though it was retained for use by __FILE__.
Clean up a number of other memory management issues with the new
quoting code, and change the stdscan implementation to one pass over
the string.
Diffstat (limited to 'stdscan.c')
-rw-r--r-- | stdscan.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -47,7 +47,7 @@ static char *stdscan_copy(char *p, int len) char *text; text = nasm_malloc(len + 1); - strncpy(text, p, len); + memcpy(text, p, len); text[len] = '\0'; if (stdscan_templen >= stdscan_tempsize) { @@ -176,15 +176,14 @@ int stdscan(void *private_data, struct tokenval *tv) } } else if (*stdscan_bufptr == '\'' || *stdscan_bufptr == '"' || *stdscan_bufptr == '`') { - /* a char constant */ - char s; + /* a quoted string */ bool rn_warn; - stdscan_bufptr = nasm_skip_string(tv->t_charptr = stdscan_bufptr); - s = *stdscan_bufptr; - tv->t_inttwo = nasm_unquote(tv->t_charptr); - if (!s) - return tv->t_type = TOKEN_ERRNUM; /* unmatched quotes */ - stdscan_bufptr++; /* skip over final quote */ + char start_quote = *stdscan_bufptr; + tv->t_charptr = stdscan_bufptr; + tv->t_inttwo = nasm_unquote(tv->t_charptr, &stdscan_bufptr); + if (*stdscan_bufptr != start_quote) + return tv->t_type = TOKEN_ERRNUM; + stdscan_bufptr++; /* Skip final quote */ tv->t_integer = readstrnum(tv->t_charptr, tv->t_inttwo, &rn_warn); /* Issue: can't readily check rn_warn, because we might be in a db family context... */ |