View Issue Details

IDProjectCategoryView StatusLast Update
0000463luatexluatex bugpublic2010-08-23 21:03
Reporterremyo Assigned ToTaco  
PrioritylowSeveritytweakReproducibilityalways
Status closedResolutionfixed 
Fixed in Version0.62.0 
Summary0000463: Small memory leaks in luatex
DescriptionLuatex exhibits several memory leaks, as shown by valgrind. The attached patch is an attempt to plug several of them.
TagsNo tags attached.

Activities

remyo

2010-08-07 13:45

reporter  

luatex.patch (3,198 bytes)   
diff --git a/source/texk/web2c/luatexdir/dvi/dvigen.w b/source/texk/web2c/luatexdir/dvi/dvigen.w
index 9033899..11e86fa 100644
--- a/source/texk/web2c/luatexdir/dvi/dvigen.w
+++ b/source/texk/web2c/luatexdir/dvi/dvigen.w
@@ -1191,10 +1191,11 @@ void write_out(halfword p)
         if (callback_id > 0) {
             lua_retval = run_callback(callback_id, "S->S", s, &ss);
             if ((lua_retval == true) && (ss != NULL))
-                s = ss;
+	      { xfree(s); s = ss; }
         }
     }
     tprint(s);
+    xfree(s);
     print_ln();
     flush_list(def_ref);
     if (j == 18) {
diff --git a/source/texk/web2c/luatexdir/tex/expand.w b/source/texk/web2c/luatexdir/tex/expand.w
index 4ca243c..419e0c2 100644
--- a/source/texk/web2c/luatexdir/tex/expand.w
+++ b/source/texk/web2c/luatexdir/tex/expand.w
@@ -344,7 +344,7 @@ void manufacture_csname(void)
     } else {
         cur_cs = null_cs;       /* the list is empty */
     }
-    xfree(ss->s);
+    free_lstring(ss);
     flush_list(r);
     if (eq_type(cur_cs) == undefined_cs_cmd) {
         eq_define(cur_cs, relax_cmd, too_big_char);     /* N.B.: The |save_stack| might change */
diff --git a/source/texk/web2c/luatexdir/tex/filename.w b/source/texk/web2c/luatexdir/tex/filename.w
index e984868..c969fb9 100644
--- a/source/texk/web2c/luatexdir/tex/filename.w
+++ b/source/texk/web2c/luatexdir/tex/filename.w
@@ -107,6 +107,7 @@ static void end_name(void)
         cur_string[area_delimiter] = '\0';
         cur_length = (unsigned) strlen((char *) cur_string);
         cur_area = make_string();
+	xfree(cur_string);
         cur_length = (unsigned) strlen((char *) s);
         cur_string = s;
     }
@@ -119,6 +120,7 @@ static void end_name(void)
         cur_string[l] = '\0';
         cur_length = (unsigned) strlen((char *) cur_string);
         cur_name = make_string();
+	xfree(cur_string);
         cur_length = (unsigned) strlen((char *) s);
         cur_string = s;
         cur_ext = make_string();
diff --git a/source/texk/web2c/luatexdir/tex/primitive.w b/source/texk/web2c/luatexdir/tex/primitive.w
index abaac09..5617031 100644
--- a/source/texk/web2c/luatexdir/tex/primitive.w
+++ b/source/texk/web2c/luatexdir/tex/primitive.w
@@ -389,6 +389,7 @@ static halfword insert_id(halfword p, const unsigned char *j, unsigned int l)
         append_char(*k);
     cs_text(p) = make_string();
     cur_length = saved_cur_length;
+    xfree(cur_string);
     cur_string = saved_cur_string;
     cur_string_size = saved_cur_string_size;
     incr(cs_count);
diff --git a/source/texk/web2c/luatexdir/tex/stringpool.h b/source/texk/web2c/luatexdir/tex/stringpool.h
index 5a4b868..a55cdac 100644
--- a/source/texk/web2c/luatexdir/tex/stringpool.h
+++ b/source/texk/web2c/luatexdir/tex/stringpool.h
@@ -115,6 +115,7 @@ extern void reset_cur_string(void);
 
 #  define restore_cur_string(u) if (u!=0) {                   \
         unsigned l = (unsigned)str_length(u);		      \
+	xfree(cur_string);                                  \
         reset_cur_string();                                 \
         str_room(l);                                        \
         memcpy(cur_string, str_string(u),l);                \
luatex.patch (3,198 bytes)   

Taco

2010-08-07 14:03

administrator   ~0000601

Thanks, applied in #3802

Issue History

Date Modified Username Field Change
2010-08-07 13:45 remyo New Issue
2010-08-07 13:45 remyo File Added: luatex.patch
2010-08-07 14:03 Taco Note Added: 0000601
2010-08-07 14:03 Taco Status new => resolved
2010-08-07 14:03 Taco Resolution open => fixed
2010-08-07 14:03 Taco Assigned To => Taco
2010-08-23 21:03 Taco Fixed in Version => 0.62.0
2010-08-23 21:03 Taco Status resolved => closed