xref: /PHP-7.3/Zend/tests/bug70262.phpt (revision 8df34610)
1--TEST--
2Bug #70262 (Accessing array crashes)
3--FILE--
4<?php
5
6$array = array();
7$array[] = 1; // make this not immutable
8
9$extra = $array; // make the refcount == 2
10
11class A {
12    public function getObj($array) {
13        $obj = new Stdclass;
14        $obj->arr = $array; // make the refcount == 3;
15        return $obj;
16    }
17}
18
19$a = new A;
20$a->getObj($array) //use function call to get a refcount == 1 IS_VAR object
21    ->arr // FETCH_OBJ_W will EXTRACT_ZVAL_PTR because getObj() result a refcount == 1 object (READY_TO_DESTROY)
22        [0] = "test"; //We will get a refcount == 3 array (not a IS_INDIRCT) in ZEND_ASSIGN_DIM_SPEC_VAR_CONST_HANDLER
23
24var_dump($array);
25?>
26--EXPECT--
27array(1) {
28  [0]=>
29  int(1)
30}
31