xref: /PHP-7.4/Zend/tests/bug71859.phpt (revision 9564998e)
1--TEST--
2Bug #71859 (zend_objects_store_call_destructors operates on realloced memory, crashing)
3--FILE--
4<?php
5class constructs_in_destructor {
6  public function __destruct() {
7    //We are now in zend_objects_store_call_destructors
8    //This causes a realloc in zend_objects_store_put
9    for ($i = 0; $i < 10000; ++$i) {
10      $GLOBALS["a$i"] = new stdClass;
11    }
12    //Returns to zend_objects_store_call_destructors, to access freed memory.
13  }
14}
15
16$a = new constructs_in_destructor;
17//Create cycle so destructors are ran only in zend_objects_store_call_destructors
18$a->a = $a;
19
20// Create some objects so zend_objects_store_call_destructors has something
21// to do after constructs_in_destructor is destroyed.
22for ($i = 0; $i < 200; ++$i) {
23  $GLOBALS["b$i"] = new stdClass;
24}
25?>
26okey
27--EXPECT--
28okey
29