[truetype] Prevent crash in `TT_Set_Named_Instance' (#56813). * src/truetype/ttgxvar.c (TT_Set_Named_Instance): Fix error handling.
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
diff --git a/ChangeLog b/ChangeLog
index 7a06ca0..0412484 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2019-08-27 Werner Lemberg <wl@gnu.org>
+ [truetype] Prevent crash in `TT_Set_Named_Instance' (#56813).
+
+ * src/truetype/ttgxvar.c (TT_Set_Named_Instance): Fix error
+ handling.
+
+2019-08-27 Werner Lemberg <wl@gnu.org>
+
[woff2] Fix compiler warnings.
* src/sfnt/sfwoff2.c (read_num_hmetrics): Remove unused argument
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 9ce61df..df5f9bb 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -3037,7 +3037,7 @@
TT_Set_Named_Instance( TT_Face face,
FT_UInt instance_index )
{
- FT_Error error = FT_ERR( Invalid_Argument );
+ FT_Error error;
GX_Blend blend;
FT_MM_Var* mmvar;
@@ -3057,7 +3057,10 @@
/* `instance_index' starts with value 1, thus `>' */
if ( instance_index > num_instances )
+ {
+ error = FT_ERR( Invalid_Argument );
goto Exit;
+ }
if ( instance_index > 0 )
{