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

chromatic at svn.parrot.org chromatic at svn.parrot.org
Fri Jun 26 14:03:03 UTC 2009


Author: chromatic
Date: Fri Jun 26 14:03:03 2009
New Revision: 39799
URL: https://trac.parrot.org/parrot/changeset/39799

Log:
[IMCC] Fixed a memory leak of the name of a file included with .include.

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

Modified: trunk/compilers/imcc/imcc.l
==============================================================================
--- trunk/compilers/imcc/imcc.l	Fri Jun 26 13:51:39 2009	(r39798)
+++ trunk/compilers/imcc/imcc.l	Fri Jun 26 14:03:03 2009	(r39799)
@@ -1224,6 +1224,7 @@
 
         IMCC_INFO(interp)->line = m->line;
         scan_string(frame, m->expansion, yyscanner);
+
         return 1;
     }
 
@@ -1240,9 +1241,14 @@
     char *ext;
     FILE *file;
 
-    if (!s || !(file = fopen(s, "r")))
+    if (!s || !(file = fopen(s, "r"))) {
+        if (frame->s.file)
+            mem_sys_free(frame->s.file);
         IMCC_fataly(interp, EXCEPTION_EXTERNAL_ERROR, strerror(errno));
+    }
 
+    if (frame->s.file)
+        mem_sys_free(frame->s.file);
     mem_sys_free(s);
     frame->s.file            = mem_sys_strdup(file_name);
     frame->s.handle          = file;

Modified: trunk/compilers/imcc/imclexer.c
==============================================================================
--- trunk/compilers/imcc/imclexer.c	Fri Jun 26 13:51:39 2009	(r39798)
+++ trunk/compilers/imcc/imclexer.c	Fri Jun 26 14:03:03 2009	(r39799)
@@ -5637,6 +5637,7 @@
 
         IMCC_INFO(interp)->line = m->line;
         scan_string(frame, m->expansion, yyscanner);
+
         return 1;
     }
 
@@ -5653,9 +5654,14 @@
     char *ext;
     FILE *file;
 
-    if (!s || !(file = fopen(s, "r")))
+    if (!s || !(file = fopen(s, "r"))) {
+        if (frame->s.file)
+            mem_sys_free(frame->s.file);
         IMCC_fataly(interp, EXCEPTION_EXTERNAL_ERROR, strerror(errno));
+    }
 
+    if (frame->s.file)
+        mem_sys_free(frame->s.file);
     mem_sys_free(s);
     frame->s.file            = mem_sys_strdup(file_name);
     frame->s.handle          = file;


More information about the parrot-commits mailing list