Author: chromatic
Date: Sat Nov 29 00:37:35 2008
New Revision: 33327
Modified:
trunk/compilers/imcc/imcc.l
trunk/compilers/imcc/imclexer.c
Log:
[IMCC] Made yylex_skip() free any str_dup()ed strings if it has to run multiple
lexing passes to skip over tokens. This cleans up one more memory leak in IMCC
macros, specifically CID #140 from Coverity Scan.
Modified: trunk/compilers/imcc/imcc.l
==============================================================================
--- trunk/compilers/imcc/imcc.l (original)
+++ trunk/compilers/imcc/imcc.l Sat Nov 29 00:37:35 2008
@@ -839,6 +839,13 @@
while (*p && c != *p)
p++;
+ /* leave loop early if it gets found */
+ if (*p == '\0')
+ break;
+
+ /* free any str_dup()ed strings */
+ if (yytext)
+ mem_sys_free(valp->s);
} while (*p != '\0');
if (c)
@@ -897,9 +904,6 @@
params->num_param = 0;
- /* See http://rt.perl.org/rt3/Ticket/Display.html?id=50920 for the saga of
this bug. */
- /* For some reason, we have to use a dupe of the macro name to pass in to
*/
- /* read_params, or we get a segfault. XXX Make it stop. */
while (c != ')') {
if (YYSTATE == heredoc2)
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR,
Modified: trunk/compilers/imcc/imclexer.c
==============================================================================
--- trunk/compilers/imcc/imclexer.c (original)
+++ trunk/compilers/imcc/imclexer.c Sat Nov 29 00:37:35 2008
@@ -5380,6 +5380,13 @@
while (*p && c != *p)
p++;
+ /* leave loop early if it gets found */
+ if (*p == '\0')
+ break;
+
+ /* free any str_dup()ed strings */
+ if (yytext)
+ mem_sys_free(valp->s);
} while (*p != '\0');
if (c)
@@ -5438,9 +5445,6 @@
params->num_param = 0;
- /* See http://rt.perl.org/rt3/Ticket/Display.html?id=50920 for the saga of
this bug. */
- /* For some reason, we have to use a dupe of the macro name to pass in to
*/
- /* read_params, or we get a segfault. XXX Make it stop. */
while (c != ')') {
if (YYSTATE == heredoc2)
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR,