summaryrefslogtreecommitdiff
path: root/Zend/zend_alloc.c
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2019-03-05 13:25:21 -0800
committerStanislav Malyshev <stas@php.net>2019-03-06 00:50:09 -0800
commitdb777e9199a94f95416ea16baf82a7d10a0bbe51 (patch)
treedddcdc2fc9fa6bc55c68cbfa15e921651c16d216 /Zend/zend_alloc.c
parentf651397b1f874a09a7d3885a7463cdf8ea6eafa7 (diff)
downloadphp-git-db777e9199a94f95416ea16baf82a7d10a0bbe51.tar.gz
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.
Diffstat (limited to 'Zend/zend_alloc.c')
-rw-r--r--Zend/zend_alloc.c4
1 files changed, 2 insertions, 2 deletions
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)