Skip to content

Commit b7a158a

Browse files
nielsdosGirgias
authored andcommitted
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 <[email protected]>
1 parent 40da996 commit b7a158a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ PHP NEWS
99
- FFI:
1010
. Fixed incorrect bitshifting and masking in ffi bitfield. (nielsdos)
1111

12+
- Opcache:
13+
. Fix incorrect page_size check. (nielsdos)
14+
1215
- Standard:
1316
. Fixed bug GH-10292 (Made the default value of the first param of srand() and
1417
mt_srand() unknown). (kocsismate)

ext/opcache/ZendAccelerator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3197,7 +3197,7 @@ static zend_result accel_post_startup(void)
31973197
size_t page_size;
31983198

31993199
page_size = zend_get_page_size();
3200-
if (!page_size && (page_size & (page_size - 1))) {
3200+
if (!page_size || (page_size & (page_size - 1))) {
32013201
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - can't get page size.");
32023202
abort();
32033203
}

0 commit comments

Comments
 (0)