[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 06fc5c24170: Correctly bisect format 12 and 8 cmap tables
From: |
Po Lu |
Subject: |
master 06fc5c24170: Correctly bisect format 12 and 8 cmap tables |
Date: |
Wed, 18 Oct 2023 01:54:24 -0400 (EDT) |
branch: master
commit 06fc5c24170b820939d3d51071b2957354edcb65
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Correctly bisect format 12 and 8 cmap tables
* src/sfnt.c (sfnt_bsearch_above): Cease returning the last
element if it is ordered below the key itself.
(sfnt_lookup_glyph_8, sfnt_lookup_glyph_12): Verify whether the
group returned is NULL.
---
src/sfnt.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/sfnt.c b/src/sfnt.c
index 360b0cd2d4d..0648e12150c 100644
--- a/src/sfnt.c
+++ b/src/sfnt.c
@@ -1122,8 +1122,8 @@ sfnt_lookup_glyph_2 (sfnt_char character,
: 0);
}
-/* Like `bsearch'. However, return the highest element above KEY if
- it could not be found. */
+/* Like `bsearch', but return the element ordered exactly above KEY if
+ one exists and KEY itself cannot be located. */
static void *
sfnt_bsearch_above (const void *key, const void *base,
@@ -1146,12 +1146,18 @@ sfnt_bsearch_above (const void *key, const void *base,
mid = low + (high - low) / 2;
sample = bytes + mid * size;
- if (compar (key, sample) > 0)
+ if ((*compar) (key, sample) > 0)
low = mid + 1;
else
high = mid;
}
+ sample = bytes + low * size;
+
+ if (low == nmemb - 1
+ && (*compar) (key, sample) > 0)
+ return NULL;
+
return (unsigned char *) bytes + low * size;
}
@@ -1287,7 +1293,7 @@ sfnt_lookup_glyph_8 (sfnt_char character,
sizeof format8->groups[0],
sfnt_compare_char);
- if (group->start_char_code > character)
+ if (!group || group->start_char_code > character)
/* No glyph matches this group. */
return 0;
@@ -1336,7 +1342,7 @@ sfnt_lookup_glyph_12 (sfnt_char character,
sizeof format12->groups[0],
sfnt_compare_char);
- if (group->start_char_code > character)
+ if (!group || group->start_char_code > character)
/* No glyph matches this group. */
return 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 06fc5c24170: Correctly bisect format 12 and 8 cmap tables,
Po Lu <=