From: Nikita Popov Date: Thu, 30 Jul 2020 08:17:37 +0000 (+0200) Subject: Check non-zero in is_power_of_two() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3690a805c15087f7f04c602e9f3c1e617060c475;p=php Check non-zero in is_power_of_two() And assert non-zero in floor_log2(). Fixes DASM_S_RANGE_I in ext/simplexml/tests/021.phpt. --- diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 5c827f4b99..107e2c5de8 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -1613,6 +1613,7 @@ static uint32_t ones32(uint32_t x) static uint32_t floor_log2(uint32_t x) { + ZEND_ASSERT(x != 0); x |= (x >> 1); x |= (x >> 2); x |= (x >> 4); @@ -1623,7 +1624,7 @@ static uint32_t floor_log2(uint32_t x) static zend_bool is_power_of_two(uint32_t x) { - return !(x & (x - 1)); + return !(x & (x - 1)) && x != 0; } static zend_bool has_concrete_type(uint32_t value_type)