View Issue Details

IDProjectCategoryView StatusLast Update
0000890luatexluatex bugpublic2015-03-21 15:00
Reporterphg Assigned ToTaco  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Summary0000890: memleak in the font library
DescriptionIn luafont.w, the return value of n_string_field() is xstrdup()’ed
on two occasions, but the function already does this job.
Steps To Reproduce\ifdefined \luatexsuppresslongerror
  \input luaotfload.sty
\fi
\font \mainfont = file:lmroman10-regular.otf at 42pt
\mainfont
%% nop
\bye
Additional InformationRun the above snippet under either the luatex-plain format or with
the luatex format of texlive.

According to Valgrind, the attached patch saves about 117 KB from leaking.

I’m running LuaTeX, Version beta-0.78.3 (TeX Live 2014/dev) (rev 4804)
TagsNo tags attached.

Activities

phg

2014-02-19 19:57

reporter  

luafont.w-font-library-memleak.patch (1,097 bytes)   
Fix memleak due to redundant call to xstrdup() in luafont.w.

Index: source/texk/web2c/luatexdir/font/luafont.w
===================================================================
diff --git a/trunk/source/texk/web2c/luatexdir/font/luafont.w b/trunk/source/texk/web2c/luatexdir/font/luafont.w
--- a/trunk/source/texk/web2c/luatexdir/font/luafont.w	(revision 4822)
+++ b/trunk/source/texk/web2c/luatexdir/font/luafont.w	(working copy)
@@ -1245,15 +1245,9 @@
         k = n_boolean_field(L, luaS_used_index, 0);
         set_charinfo_used(co, k);
         s = n_string_field(L, luaS_name_index, NULL);
-        if (s != NULL)
-            set_charinfo_name(co, xstrdup(s));
-        else
-            set_charinfo_name(co, NULL);
+        set_charinfo_name(co, s);
         s = n_string_field(L, luaS_tounicode_index, NULL);
-        if (s != NULL)
-            set_charinfo_tounicode(co, xstrdup(s));
-        else
-            set_charinfo_tounicode(co, NULL);
+        set_charinfo_tounicode(co, s);
 
         if (has_math) {
             j = n_numeric_field(L, luaS_top_accent_index, INT_MIN);

Hans Hagen

2014-02-20 09:29

manager   ~0001225

fyi: luigi and i are currently optimizing / normalizing some of that code but part of that will probably show up after the frozen tex live release.

Taco

2014-03-14 11:58

administrator   ~0001247

superceded by intermediate changes to luafont.w

Issue History

Date Modified Username Field Change
2014-02-19 19:57 phg New Issue
2014-02-19 19:57 phg File Added: luafont.w-font-library-memleak.patch
2014-02-20 09:29 Hans Hagen Note Added: 0001225
2014-03-14 11:58 Taco Note Added: 0001247
2014-03-14 11:58 Taco Status new => resolved
2014-03-14 11:58 Taco Resolution open => no change required
2014-03-14 11:58 Taco Assigned To => Taco
2015-03-21 15:00 Hans Hagen Status resolved => closed