View Issue Details

IDProjectCategoryView StatusLast Update
0000889luatexluatex bugpublic2015-03-21 15:00
Reporterphg Assigned ToTaco  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Summary0000889: memleak in fontloader.info()
DescriptionWhen loading a font with fontloader.info() all of the SplineFont structure is not correctly deallocated.
Can be fixed by adding further lines from SFFillFromTTF() to SFFillFromTTFInfo.
Steps To Reproduce#!/usr/bin/env texlua

local main = function ()
  local fontinfo = fontloader.info (arg [1] or os.exit(1))
  return 0
end

return main ()
Additional InformationThe snippet above leaks 395 bytes if run on Iwona-Regular.otf (Luatex version 0.78.3, r4804).
With the patch applied, both leaks are fixed.
TagsNo tags attached.

Activities

phg

2014-02-16 23:01

reporter  

parsettf.c-fontloader-info-memleak.patch (582 bytes)   
Index: source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
===================================================================
--- source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c	(revision 4817)
+++ source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c	(working copy)
@@ -6050,6 +6050,11 @@
     sf->units_per_em = info->emsize ;
     sf->pfminfo = info->pfminfo ;
 
+    free(info->savetab);
+    if ( sf->copyright==NULL )
+	sf->copyright = info->copyright;
+    else
+	free( info->copyright );
 return( sf );
 }
 

phg

2014-02-18 07:15

reporter  

luafflib.c-fontloader-info-memleak.patch (638 bytes)   
Index: source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
===================================================================
--- source/texk/web2c/luatexdir/luafontloader/src/luafflib.c	(revision 4822)
+++ source/texk/web2c/luatexdir/luafontloader/src/luafflib.c	(working copy)
@@ -3226,7 +3226,12 @@
                         fontname);
         return 2;
     }
+
+    gww_error_count = 0;
     sf = ReadSplineFontInfo((char *) fontname, openflags);
+    if (gww_error_count > 0)
+        gwwv_errors_free();
+
     if (sf == NULL) {
         lua_pushnil(L);
         lua_pushfstring(L, "font loading failed for %s\n", fontname);

phg

2014-02-18 07:19

reporter   ~0001224

Last edited: 2014-02-18 07:20

There’s a second memory leak whenever fontloader.info() succeeded
by a call to fontloader.open().
It is caused by the former not cleaning up Fontforge error messages
after loading a font.
To reproduce:

-------------------------------------------------------------------------------


#!/usr/bin/env texlua

local main = function ()
  local fontname = arg [1] or os.exit(1)
  --[[ this leaks parts of the SplineFont ]]
  local fontinfo = fontloader.info (fontname)
  --[[ this leaks errors ]]
  local rawfont = fontloader.open (fontname)
  return 0
end

return main ()

-------------------------------------------------------------------------------

See attached patch for luafflib.c

Taco

2014-03-14 12:09

administrator   ~0001248

both patches applied

Issue History

Date Modified Username Field Change
2014-02-16 23:01 phg New Issue
2014-02-16 23:01 phg File Added: parsettf.c-fontloader-info-memleak.patch
2014-02-18 07:15 phg File Added: luafflib.c-fontloader-info-memleak.patch
2014-02-18 07:19 phg Note Added: 0001224
2014-02-18 07:20 phg Note Edited: 0001224
2014-03-14 12:09 Taco Note Added: 0001248
2014-03-14 12:09 Taco Status new => resolved
2014-03-14 12:09 Taco Resolution open => fixed
2014-03-14 12:09 Taco Assigned To => Taco
2015-03-21 15:00 Hans Hagen Status resolved => closed