ref: 577a67cc1f129e3ab240fcc47bf6f31cf6996b8e
parent: e8fd02aa39eddfadcd4a0153c3026ef42c7c54a9
author: Miguel Pineiro Jr <mpj@pineiro.cc>
date: Mon Aug 29 08:57:58 EDT 2022
Fix leak of regex string representations
The lexer returns a copy of a regular expression's string
representation which is then leaked during parsing. Since the only
consumer of that copy makes a copy of the copy (makedfa via mkdfa),
just return a pointer to the original string.
Test with:
valgrind --leak-check=full a.out '/123/; /456/' </dev/null
Reported by Todd C. Miller.
--- a/lex.c
+++ b/lex.c
@@ -545,7 +545,7 @@
*bp = 0;
if (c == 0)
SYNTAX("non-terminated regular expression %.10s...", buf);- yylval.s = tostring(buf);
+ yylval.s = buf;
unput('/');RET(REGEXPR);
}
--
⑨