Commit 594156586b888805681a7085a780bd743fb180bd

Werner Lemberg 2019-08-27T14:07:14

[truetype] Prevent crash in `TT_Set_Named_Instance' (#56813). * src/truetype/ttgxvar.c (TT_Set_Named_Instance): Fix error handling.

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 )
     {