[svn:parrot] r39484 - trunk/compilers/imcc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Tue Jun 9 23:13:45 UTC 2009


Author: chromatic
Date: Tue Jun  9 23:13:44 2009
New Revision: 39484
URL: https://trac.parrot.org/parrot/changeset/39484

Log:
[IMCC] Plugged a memory leak of the comma separating macro parameters (yes,
this is getting awfully specific).

Modified:
   trunk/compilers/imcc/imcc.l
   trunk/compilers/imcc/imclexer.c

Modified: trunk/compilers/imcc/imcc.l
==============================================================================
--- trunk/compilers/imcc/imcc.l	Tue Jun  9 22:52:10 2009	(r39483)
+++ trunk/compilers/imcc/imcc.l	Tue Jun  9 23:13:44 2009	(r39484)
@@ -702,7 +702,8 @@
             snprintf(label, len, "local__%s__%s__$:",
                 IMCC_INFO(interp)->cur_macro_name, yytext+1);
 
-            /* XXX: free valp->s if it exists? */
+            if (valp->s)
+                mem_sys_free(valp->s);
             valp->s = label;
         }
 
@@ -717,6 +718,8 @@
             snprintf(label, len, "local__%s__%s__$",
                 IMCC_INFO(interp)->cur_macro_name, yytext+2);
 
+            if (valp->s)
+                mem_sys_free(valp->s);
             valp->s = label;
         }
 
@@ -931,6 +934,8 @@
             current                           = str_dup("");
             len                               = 0;
 
+            if (val.s)
+                mem_sys_free(val.s);
             c = yylex_skip(&val, interp, " \n", yyscanner);
         }
         else if (need_id && (*current || c != IDENTIFIER) && c != ' ') {

Modified: trunk/compilers/imcc/imclexer.c
==============================================================================
--- trunk/compilers/imcc/imclexer.c	Tue Jun  9 22:52:10 2009	(r39483)
+++ trunk/compilers/imcc/imclexer.c	Tue Jun  9 23:13:44 2009	(r39484)
@@ -3873,7 +3873,8 @@
             snprintf(label, len, "local__%s__%s__$:",
                 IMCC_INFO(interp)->cur_macro_name, yytext+1);
 
-            /* XXX: free valp->s if it exists? */
+            if (valp->s)
+                mem_sys_free(valp->s);
             valp->s = label;
         }
 
@@ -3882,7 +3883,7 @@
 	YY_BREAK
 case 139:
 YY_RULE_SETUP
-#line 712 "compilers/imcc/imcc.l"
+#line 713 "compilers/imcc/imcc.l"
 {
         if (valp) {
             const size_t len = strlen(IMCC_INFO(interp)->cur_macro_name) + yyleng + 12;
@@ -3891,6 +3892,8 @@
             snprintf(label, len, "local__%s__%s__$",
                 IMCC_INFO(interp)->cur_macro_name, yytext+2);
 
+            if (valp->s)
+                mem_sys_free(valp->s);
             valp->s = label;
         }
 
@@ -3899,49 +3902,49 @@
 	YY_BREAK
 case 140:
 YY_RULE_SETUP
-#line 726 "compilers/imcc/imcc.l"
+#line 729 "compilers/imcc/imcc.l"
 /* skip leading ws */;
 	YY_BREAK
 case 141:
 YY_RULE_SETUP
-#line 727 "compilers/imcc/imcc.l"
+#line 730 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, ' ');
 	YY_BREAK
 case 142:
 YY_RULE_SETUP
-#line 728 "compilers/imcc/imcc.l"
+#line 731 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, REG);
 	YY_BREAK
 case 143:
 YY_RULE_SETUP
-#line 729 "compilers/imcc/imcc.l"
+#line 732 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, REG);
 	YY_BREAK
 case 144:
 YY_RULE_SETUP
-#line 730 "compilers/imcc/imcc.l"
+#line 733 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, IDENTIFIER);
 	YY_BREAK
 case 145:
 YY_RULE_SETUP
-#line 731 "compilers/imcc/imcc.l"
+#line 734 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, MACRO);
 	YY_BREAK
 case 146:
 YY_RULE_SETUP
-#line 732 "compilers/imcc/imcc.l"
+#line 735 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, yytext[0]);
 	YY_BREAK
 case YY_STATE_EOF(macro):
-#line 733 "compilers/imcc/imcc.l"
+#line 736 "compilers/imcc/imcc.l"
 yyterminate();
 	YY_BREAK
 case 147:
 YY_RULE_SETUP
-#line 735 "compilers/imcc/imcc.l"
+#line 738 "compilers/imcc/imcc.l"
 ECHO;
 	YY_BREAK
-#line 3945 "compilers/imcc/imclexer.c"
+#line 3948 "compilers/imcc/imclexer.c"
 case YY_STATE_EOF(pod):
 case YY_STATE_EOF(cmt1):
 case YY_STATE_EOF(cmt2):
@@ -5143,7 +5146,7 @@
 
 #define YYTABLES_NAME "yytables"
 
-#line 735 "compilers/imcc/imcc.l"
+#line 738 "compilers/imcc/imcc.l"
 
 
 
@@ -5344,6 +5347,8 @@
             current                           = str_dup("");
             len                               = 0;
 
+            if (val.s)
+                mem_sys_free(val.s);
             c = yylex_skip(&val, interp, " \n", yyscanner);
         }
         else if (need_id && (*current || c != IDENTIFIER) && c != ' ') {


More information about the parrot-commits mailing list