Fix incorrect page_size check

The current check always evaluated to false because if `!page_size`
is true, then `page_size & (page_size - 1)` equals `0 & (0 - 1)` which
is always 0. The if condition is meant to check if page_size is zero or
not a power of two, thus we must change the AND to an OR to fix this
issue.

Closes GH-10427

Signed-off-by: George Peter Banyard <girgias@php.net>
This commit is contained in:
Niels Dossche 2023-01-23 22:11:08 +01:00 committed by George Peter Banyard
parent 40da9961f2
commit b7a158a19b
No known key found for this signature in database
GPG key ID: 3306078E3194AEBD
2 changed files with 4 additions and 1 deletions

3
NEWS
View file

@ -9,6 +9,9 @@ PHP NEWS
- FFI:
. Fixed incorrect bitshifting and masking in ffi bitfield. (nielsdos)
- Opcache:
. Fix incorrect page_size check. (nielsdos)
- Standard:
. Fixed bug GH-10292 (Made the default value of the first param of srand() and
mt_srand() unknown). (kocsismate)

View file

@ -3197,7 +3197,7 @@ static zend_result accel_post_startup(void)
size_t page_size;
page_size = zend_get_page_size();
if (!page_size && (page_size & (page_size - 1))) {
if (!page_size || (page_size & (page_size - 1))) {
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - can't get page size.");
abort();
}