The page size calculation did not account for the size of the
stack header (or rather it did account for it, but in the wrong
direction...)
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2016 PHP 7.0.11
+- Core:
+ . Fixed bug #72767 (PHP Segfaults when trying to expand an infinite operator).
+ (Nikita)
+
- GD:
. Fixed bug #72709 (imagesetstyle() causes OOB read for empty $styles). (cmb)
--- /dev/null
+--TEST--
+Bug #72767: PHP Segfaults when trying to expand an infinite operator
+--FILE--
+<?php
+
+function test() {}
+$iterator = new LimitIterator(
+ new InfiniteIterator(new ArrayIterator([42])),
+ 0, 17000
+);
+test(...$iterator);
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
((ZEND_VM_STACK_PAGE_SLOTS(gen) - ZEND_VM_STACK_HEADER_SLOTS) * sizeof(zval))
#define ZEND_VM_STACK_PAGE_ALIGNED_SIZE(gen, size) \
- (((size) + (ZEND_VM_STACK_FREE_PAGE_SIZE(gen) - 1)) & ~(ZEND_VM_STACK_PAGE_SIZE(gen) - 1))
+ (((size) + ZEND_VM_STACK_HEADER_SLOTS * sizeof(zval) \
+ + (ZEND_VM_STACK_PAGE_SIZE(gen) - 1)) & ~(ZEND_VM_STACK_PAGE_SIZE(gen) - 1))
static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend_vm_stack prev) {
zend_vm_stack page = (zend_vm_stack)emalloc(size);