nasm_quote: Use memcpy only if length provided

No need to call memcpy on empty strings

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2010-09-07 09:52:47 +04:00
parent 49cd6fbccf
commit e165c1b69a

View File

@ -108,7 +108,8 @@ char *nasm_quote(char *str, size_t len)
nstr = nasm_malloc(len+3);
nstr[0] = nstr[len+1] = sq_ok ? '\'' : '\"';
nstr[len+2] = '\0';
memcpy(nstr+1, str, len);
if (len > 0)
memcpy(nstr+1, str, len);
} else {
/* Need to use `...` quoted syntax */
nstr = nasm_malloc(qlen+3);