Blame SOURCES/freetype-2.10.4-avoid-invalid-face-index.patch

e79b8e
From 53dfdcd8198d2b3201a23c4bad9190519ba918db Mon Sep 17 00:00:00 2001
e79b8e
From: Werner Lemberg <wl@gnu.org>
e79b8e
Date: Thu, 17 Mar 2022 19:24:16 +0100
e79b8e
Subject: [PATCH] [sfnt] Avoid invalid face index.
e79b8e
e79b8e
Fixes #1138.
e79b8e
e79b8e
* src/sfnt/sfobjs.c (sfnt_init_face), src/sfnt/sfwoff2.c (woff2_open_font):
e79b8e
Check `face_index` before decrementing.
e79b8e
---
e79b8e
 src/sfnt/sfobjs.c  | 2 +-
e79b8e
 src/sfnt/sfwoff2.c | 2 +-
e79b8e
 2 files changed, 2 insertions(+), 2 deletions(-)
e79b8e
e79b8e
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
e79b8e
index f9d4d3858..9771c35df 100644
e79b8e
--- a/src/sfnt/sfobjs.c
e79b8e
+++ b/src/sfnt/sfobjs.c
e79b8e
@@ -566,7 +566,7 @@
e79b8e
     face_index = FT_ABS( face_instance_index ) & 0xFFFF;
e79b8e
 
e79b8e
     /* value -(N+1) requests information on index N */
e79b8e
-    if ( face_instance_index < 0 )
e79b8e
+    if ( face_instance_index < 0 && face_index > 0 )
e79b8e
       face_index--;
e79b8e
 
e79b8e
     if ( face_index >= face->ttc_header.count )
e79b8e
diff --git a/src/sfnt/sfwoff2.c b/src/sfnt/sfwoff2.c
e79b8e
index cb1e0664a..165b875e5 100644
e79b8e
--- a/src/sfnt/sfwoff2.c
e79b8e
+++ b/src/sfnt/sfwoff2.c
e79b8e
@@ -2085,7 +2085,7 @@
e79b8e
     /* Validate requested face index. */
e79b8e
     *num_faces = woff2.num_fonts;
e79b8e
     /* value -(N+1) requests information on index N */
e79b8e
-    if ( *face_instance_index < 0 )
e79b8e
+    if ( *face_instance_index < 0 && face_index > 0 )
e79b8e
       face_index--;
e79b8e
 
e79b8e
     if ( face_index >= woff2.num_fonts )
e79b8e
-- 
e79b8e
2.35.1
e79b8e