Commit 575b78d9e3b9c701edb5087aa1c5f9c4031d3548

Sebastian Rasmussen 2020-06-18T15:12:03

[cff] Fix memory leak (#58610). * src/cff/cffobjs.c (cff_size_init): When the call to `funcs->create' fails, make sure to free `internal'.

diff --git a/ChangeLog b/ChangeLog
index b80f16b..326dfce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-06-19  Sebastian Rasmussen  <sebras@gmail.com>
+
+	[cff] Fix memory leak (#58610).
+
+	* src/cff/cffobjs.c (cff_size_init): When the call to
+	`funcs->create' fails, make sure to free `internal'.
+
 2020-06-19  Werner Lemberg  <wl@gnu.org>
 
 	* src/cff/cffload.c (cff_index_get_pointers): Rename `t' to `tbl'.
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 981bc70..252f58a 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -166,15 +166,16 @@
     FT_Error           error = FT_Err_Ok;
     PSH_Globals_Funcs  funcs = cff_size_get_globals_funcs( size );
 
+    FT_Memory     memory   = cffsize->face->memory;
+    CFF_Internal  internal = NULL;
+
 
     if ( funcs )
     {
-      CFF_Face      face     = (CFF_Face)cffsize->face;
-      CFF_Font      font     = (CFF_Font)face->extra.data;
-      CFF_Internal  internal = NULL;
+      CFF_Face  face = (CFF_Face)cffsize->face;
+      CFF_Font  font = (CFF_Font)face->extra.data;
 
       PS_PrivateRec  priv;
-      FT_Memory      memory = cffsize->face->memory;
 
       FT_UInt  i;
 
@@ -206,6 +207,9 @@
     size->strike_index = 0xFFFFFFFFUL;
 
   Exit:
+    if ( error )
+      FT_FREE( internal );
+
     return error;
   }