[cff] Fix memory leak (#58610). * src/cff/cffobjs.c (cff_size_init): When the call to `funcs->create' fails, make sure to free `internal'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
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;
}