47 lines
1.5 KiB
Diff
47 lines
1.5 KiB
Diff
From 818eea8aa682f867e4fbeb9794959a28864e4acc Mon Sep 17 00:00:00 2001
|
|
From: Werner Lemberg <wl@gnu.org>
|
|
Date: Thu, 17 Mar 2022 19:24:16 +0100
|
|
Subject: [PATCH] [sfnt] Avoid invalid face index.
|
|
|
|
Fixes #1138.
|
|
|
|
* src/sfnt/sfobjs.c (sfnt_init_face), src/sfnt/sfwoff2.c (woff2_open_font):
|
|
Check `face_index` before decrementing.
|
|
|
|
Backport: https://gitlab.freedesktop.org/freetype/freetype/-/commit/53dfdcd8198d2b3201a23c4bad9190519ba918db
|
|
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
|
|
---
|
|
src/sfnt/sfobjs.c | 2 +-
|
|
src/sfnt/sfwoff2.c | 2 +-
|
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
|
|
index 789102479..ea17ca8f4 100644
|
|
--- a/src/sfnt/sfobjs.c
|
|
+++ b/src/sfnt/sfobjs.c
|
|
@@ -566,7 +566,7 @@
|
|
face_index = FT_ABS( face_instance_index ) & 0xFFFF;
|
|
|
|
/* value -(N+1) requests information on index N */
|
|
- if ( face_instance_index < 0 )
|
|
+ if ( face_instance_index < 0 && face_index > 0 )
|
|
face_index--;
|
|
|
|
if ( face_index >= face->ttc_header.count )
|
|
diff --git a/src/sfnt/sfwoff2.c b/src/sfnt/sfwoff2.c
|
|
index 5ee8dea28..2da697d69 100644
|
|
--- a/src/sfnt/sfwoff2.c
|
|
+++ b/src/sfnt/sfwoff2.c
|
|
@@ -2086,7 +2086,7 @@
|
|
/* Validate requested face index. */
|
|
*num_faces = woff2.num_fonts;
|
|
/* value -(N+1) requests information on index N */
|
|
- if ( *face_instance_index < 0 )
|
|
+ if ( *face_instance_index < 0 && face_index > 0 )
|
|
face_index--;
|
|
|
|
if ( face_index >= woff2.num_fonts )
|
|
--
|
|
2.37.3
|
|
|