mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix shifting signed values too far
Signed shift of 31 for int and 63 for long is flagged as undefined behavior by UBSan (-fsanitize=undefined) and seems to be indeed so according to the standard. The patch converts such cases to use unsigned.
This commit is contained in:
parent
f651397b1f
commit
db777e9199
4 changed files with 6 additions and 6 deletions
|
@ -587,12 +587,12 @@ static zend_always_inline int zend_mm_bitset_is_set(zend_mm_bitset *bitset, int
|
|||
|
||||
static zend_always_inline void zend_mm_bitset_set_bit(zend_mm_bitset *bitset, int bit)
|
||||
{
|
||||
bitset[bit / ZEND_MM_BITSET_LEN] |= (Z_L(1) << (bit & (ZEND_MM_BITSET_LEN-1)));
|
||||
bitset[bit / ZEND_MM_BITSET_LEN] |= (Z_UL(1) << (bit & (ZEND_MM_BITSET_LEN-1)));
|
||||
}
|
||||
|
||||
static zend_always_inline void zend_mm_bitset_reset_bit(zend_mm_bitset *bitset, int bit)
|
||||
{
|
||||
bitset[bit / ZEND_MM_BITSET_LEN] &= ~(Z_L(1) << (bit & (ZEND_MM_BITSET_LEN-1)));
|
||||
bitset[bit / ZEND_MM_BITSET_LEN] &= ~(Z_UL(1) << (bit & (ZEND_MM_BITSET_LEN-1)));
|
||||
}
|
||||
|
||||
static zend_always_inline void zend_mm_bitset_set_range(zend_mm_bitset *bitset, int start, int len)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue