[ot-map] Allocate top mask bit as global bit
Avoids undefined-shift of 32 in the following line: map->mask = (1u << (next_bit + bits_needed)) - (1u << next_bit) Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=1219263
This commit is contained in:
parent
f698fe5aee
commit
a150baf32c
|
@ -150,9 +150,8 @@ void
|
||||||
hb_ot_map_builder_t::compile (hb_ot_map_t &m,
|
hb_ot_map_builder_t::compile (hb_ot_map_t &m,
|
||||||
const hb_ot_shape_plan_key_t &key)
|
const hb_ot_shape_plan_key_t &key)
|
||||||
{
|
{
|
||||||
static_assert ((!(HB_GLYPH_FLAG_DEFINED & (HB_GLYPH_FLAG_DEFINED + 1))), "");
|
unsigned int global_bit_shift = 8 * sizeof (hb_mask_t) - 1;
|
||||||
unsigned int global_bit_mask = HB_GLYPH_FLAG_DEFINED + 1;
|
unsigned int global_bit_mask = 1u << global_bit_shift;
|
||||||
unsigned int global_bit_shift = hb_popcount (HB_GLYPH_FLAG_DEFINED);
|
|
||||||
|
|
||||||
m.global_mask = global_bit_mask;
|
m.global_mask = global_bit_mask;
|
||||||
|
|
||||||
|
@ -205,7 +204,8 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
|
||||||
|
|
||||||
|
|
||||||
/* Allocate bits now */
|
/* Allocate bits now */
|
||||||
unsigned int next_bit = global_bit_shift + 1;
|
static_assert ((!(HB_GLYPH_FLAG_DEFINED & (HB_GLYPH_FLAG_DEFINED + 1))), "");
|
||||||
|
unsigned int next_bit = hb_popcount (HB_GLYPH_FLAG_DEFINED) + 1;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < feature_infos.length; i++)
|
for (unsigned int i = 0; i < feature_infos.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -220,7 +220,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
|
||||||
/* Limit bits per feature. */
|
/* Limit bits per feature. */
|
||||||
bits_needed = hb_min (HB_OT_MAP_MAX_BITS, hb_bit_storage (info->max_value));
|
bits_needed = hb_min (HB_OT_MAP_MAX_BITS, hb_bit_storage (info->max_value));
|
||||||
|
|
||||||
if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t))
|
if (!info->max_value || next_bit + bits_needed >= global_bit_shift)
|
||||||
continue; /* Feature disabled, or not enough bits. */
|
continue; /* Feature disabled, or not enough bits. */
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,7 +274,6 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
|
||||||
}
|
}
|
||||||
map->_1_mask = (1u << map->shift) & map->mask;
|
map->_1_mask = (1u << map->shift) & map->mask;
|
||||||
map->needs_fallback = !found;
|
map->needs_fallback = !found;
|
||||||
|
|
||||||
}
|
}
|
||||||
feature_infos.shrink (0); /* Done with these */
|
feature_infos.shrink (0); /* Done with these */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue