diff --git a/check/fixes.frm b/check/fixes.frm index ed00e021..265a7209 100644 --- a/check/fixes.frm +++ b/check/fixes.frm @@ -2285,3 +2285,15 @@ Print +s; assert succeeded? assert result("F3") =~ expr("+D") *--#] Issue405 : +*--#[ Issue434 : +* Memory error with macros with arguments +* The loop (appending a variable and calling the macro) is repeated enough +* to hit the problem (Valgrind error). +#define var(a) "`~a'" +#do n=1,{12*2^5} + #define x + #message `var(`n')' +#enddo +.end +assert succeeded? +*--#] Issue434 : diff --git a/sources/pre.c b/sources/pre.c index b6697201..6aa45bf4 100644 --- a/sources/pre.c +++ b/sources/pre.c @@ -310,6 +310,7 @@ UBYTE GetChar(int level) */ int nargs = 1; PREVAR *p; + size_t p_offset; *s++ = 0; namebuf[i-2] = 0; if ( StrICmp(namebuf,(UBYTE *)"random_") == 0 ) { UBYTE *ranvalue; @@ -367,6 +368,7 @@ UBYTE GetChar(int level) while ( *s ) s++; s++; t = p->argnames; + p_offset = p - PreVar; for ( j = 0; j < p->nargs; j++ ) { if ( ( nargs == p->nargs-1 ) && ( *t == '?' ) ) { PutPreVar(t,0,0,0); @@ -376,6 +378,7 @@ UBYTE GetChar(int level) while ( *s ) s++; s++; } + p = PreVar + p_offset; while ( *t ) t++; t++; }