diff --git a/asm/preproc.c b/asm/preproc.c index ac42131e9..9db58c5e7 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -6817,7 +6817,7 @@ static int expand_mmacro(Token * tline) */ nasm_newn(paramlen, nparam+1); - for (i = 1; (t = params[i]); i++) { + for (i = 1; i < nparam+1 && (t = params[i]); i++) { bool braced = false; int brace = 0; int white = 0; diff --git a/nasmlib/alloc.c b/nasmlib/alloc.c index e25e0e0ab..df2e02b48 100644 --- a/nasmlib/alloc.c +++ b/nasmlib/alloc.c @@ -104,8 +104,10 @@ void *nasm_realloc(void *q, size_t size) void nasm_free(void *q) { - if (q) + if (q){ free(q); + q = NULL; + } } char *nasm_strdup(const char *s)