mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
220880ad2d
When performing an RW modification of an array offset, the undefined offset warning may call an error handler / OB callback, which may destroy the array we're supposed to change. Detect this by temporarily incrementing the reference count. If we find that the array has been modified/destroyed in the meantime, we do nothing -- the execution model here would be that the modification has happened on the destroyed version of the array.
32 lines
455 B
PHP
32 lines
455 B
PHP
--TEST--
|
|
Bug #78598: Changing array during undef index RW error segfaults
|
|
--FILE--
|
|
<?php
|
|
|
|
$my_var = null;
|
|
set_error_handler(function() use(&$my_var) {
|
|
$my_var = 0;
|
|
});
|
|
|
|
$my_var[0] .= "xyz";
|
|
var_dump($my_var);
|
|
|
|
$my_var = null;
|
|
$my_var[0][0][0] .= "xyz";
|
|
var_dump($my_var);
|
|
|
|
$my_var = null;
|
|
$my_var["foo"] .= "xyz";
|
|
var_dump($my_var);
|
|
|
|
$my_var = null;
|
|
$my_var["foo"]["bar"]["baz"] .= "xyz";
|
|
var_dump($my_var);
|
|
|
|
?>
|
|
--EXPECT--
|
|
int(0)
|
|
int(0)
|
|
int(0)
|
|
int(0)
|