Closed millert closed 2 years ago
Hi, millert:
What do you think of this alternative?
diff --git a/lex.c b/lex.c
index d7b2d03..c162a70 100644
--- a/lex.c
+++ b/lex.c
@@ -545,7 +545,7 @@ int regexpr(void)
*bp = 0;
if (c == 0)
SYNTAX("non-terminated regular expression %.10s...", buf);
- yylval.s = tostring(buf);
+ yylval.s = buf;
unput('/');
RET(REGEXPR);
}
This tostring is the source of the leaked memory and it's unnecessary (makedfa->mkdfa will make a copy).
The last bit of your commit seems to regard an unrelated grammatical matter which my proposal does not address.
Take care, Miguel
Yes, that looks better indeed. I didn't intend for that last hunk to be included, too many tree :-)
Closing in favor of the fix from @mpinjr
The string returned by reg_expr was never freed after conversion to a dfa.