[set] Fix undefined-behavior shift in _previous()
harfbuzz/src/hb-set.hh:138:43: runtime error: shift exponent 64 is too large for 64-bit type 'hb_set_t::page_t::elt_t' (aka 'unsigned long long')
This commit is contained in:
parent
5fddc5f169
commit
e5c7ee9f75
|
@ -135,7 +135,11 @@ struct hb_set_t
|
||||||
unsigned int i = m / ELT_BITS;
|
unsigned int i = m / ELT_BITS;
|
||||||
unsigned int j = m & ELT_MASK;
|
unsigned int j = m & ELT_MASK;
|
||||||
|
|
||||||
const elt_t vv = v[i] & ((elt_t (1) << (j + 1)) - 1);
|
/* Fancy mask to avoid shifting by elt_t bitsize, which is undefined. */
|
||||||
|
const elt_t mask = j < 8 * sizeof (elt_t) - 1 ?
|
||||||
|
((elt_t (1) << (j + 1)) - 1) :
|
||||||
|
(elt_t) -1;
|
||||||
|
const elt_t vv = v[i] & mask;
|
||||||
const elt_t *p = &vv;
|
const elt_t *p = &vv;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue