[face] Ignore named-instance bits in hb_face_create_or_fail() (#6571)

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6567
This commit is contained in:
Khaled Hosny authored and GitHub committed 2026-11-04 12:02:49 -06:00
1 parent b269f9e1ad
commit bd306afedb
2 files changed
+21 -1

No files matched your search

+1 -1
View File
@@ -290,7 +290,7 @@ hb_face_create_or_fail (hb_blob_t *blob,
unsigned int index)
{
unsigned num_faces = hb_face_count (blob);
if (index >= num_faces)
if ((index & 0xFFFFu) >= num_faces)
return nullptr;
hb_face_t *face = hb_face_create (blob, index);
+20
View File
@@ -75,6 +75,25 @@ test_create_from_blob_using (const void *user_data)
hb_face_destroy (face);
}
static void
test_create_or_fail_named_instance_index (void)
{
hb_blob_t *blob = hb_blob_create_from_file_or_fail (font_file);
g_assert_nonnull (blob);
unsigned index = face_index | (1u << 16);
hb_face_t *face = hb_face_create_or_fail (blob, index);
g_assert_nonnull (face);
g_assert_cmpuint (hb_face_get_index (face), ==, index);
test_face (face);
hb_face_destroy (face);
face = hb_face_create_or_fail (blob, hb_face_count (blob) | (1u << 16));
g_assert_null (face);
hb_blob_destroy (blob);
}
static void
test_default_loader_environment (void)
{
@@ -124,6 +143,7 @@ main (int argc, char **argv)
font_file = hb_test_resolve_path (font_file);
hb_test_add (test_create_or_fail_named_instance_index);
hb_test_add (test_default_loader_environment);
hb_test_add_flavor ("", test_create_from_file_using);
hb_test_add_flavor ("", test_create_from_blob_using);