php-src/Zend/tests/incdec_undef.phpt
Nikita Popov 22b6aac66f Fix inc/dec of undef var with error handler
Set the variable to null after emitting the undef var notice
rather than before. This avoids an assertion failure if the var
is unset by the error handler.

The flip side is that this may cause a leak instead, but that's
the more harmless outcome.

Fixes oss-fuzz #36604.
2021-10-19 14:19:22 +02:00

26 lines
366 B
PHP

--TEST--
Inc/dec undef var with error handler
--FILE--
<?php
set_error_handler(function($_, $m) {
echo "$m\n";
unset($GLOBALS['x']);
});
var_dump($x--);
unset($x);
var_dump($x++);
unset($x);
var_dump(--$x);
unset($x);
var_dump(++$x);
?>
--EXPECT--
Undefined variable $x
NULL
Undefined variable $x
NULL
Undefined variable $x
NULL
Undefined variable $x
int(1)