ref: 351fc4b4a4e6ac8036df7248ab6c24129ca13269
parent: 2a03e5d9fb1392f1c57f26589cd3d5efb19f4fa1
author: Werner Lemberg <[email protected]>
date: Tue Mar 29 05:13:13 EDT 2016
[pfr] Fix binary search (#47514). * src/pfr/pfrsbit.c (pfr_lookup_bitmap_data): Handle border conditions correctly.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2016-03-29 Werner Lemberg <[email protected]>
+ [pfr] Fix binary search (#47514).
+
+ * src/pfr/pfrsbit.c (pfr_lookup_bitmap_data): Handle border
+ conditions correctly.
+
+2016-03-29 Werner Lemberg <[email protected]>
+
[pfr] Minor.
* src/pfr/pfrsbit.c (pfr_lookup_bitmap_data): Replace `left',
--- a/src/pfr/pfrsbit.c
+++ b/src/pfr/pfrsbit.c
@@ -364,13 +364,12 @@
else
code = PFR_NEXT_BYTE( buff );
- if ( code == char_code )
- goto Found_It;
-
- if ( code < char_code )
- min = mid;
- else
+ if ( char_code < code )
max = mid;
+ else if ( char_code > code )
+ min = mid + 1;
+ else
+ goto Found_It;
}
Fail:
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -3104,7 +3104,7 @@
if ( char_code < start )
max = mid;
- else if ( char_code > start+cnt )
+ else if ( char_code > start + cnt )
min = mid + 1;
else
return TRUE;