From db777e9199a94f95416ea16baf82a7d10a0bbe51 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Tue, 5 Mar 2019 13:25:21 -0800 Subject: 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. --- Zend/zend_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zend/zend_alloc.c') diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 2165c532f5..83eee90312 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -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) -- cgit v1.2.1