php-src/Zend/tests/bug70547.phpt
Nikita Popov d65d3f5298 Fix bug #79108
Don't expose references in debug_backtrace() or exception traces.
This is regardless of whether the argument is by-reference or not.

As a side-effect of this change, exception traces may now acquire
the interior value of a reference, which may be unexpected for
some internal functions. This is what necessitated the change in
the spl_array sort implementation.
2020-07-24 12:23:34 +02:00

100 lines
1.4 KiB
PHP

--TEST--
Bug #70547 (unsetting function variables corrupts backtrace)
--FILE--
<?php
function brokenTrace($arg1, &$arg2, $arg3){
backtraceWrapper();
var_dump(func_get_args());
unset($arg3);
var_dump(func_get_arg(0));
var_dump(func_get_arg(1));
var_dump(func_get_arg(2));
var_dump(func_get_arg(3));
backtraceWrapper();
unset($arg1);
var_dump(func_get_args());
backtraceWrapper();
unset($arg2);
backtraceWrapper();
var_dump(func_get_arg(0));
var_dump(func_get_arg(1));
var_dump(func_get_arg(2));
var_dump(func_get_arg(3));
}
$arg2 = "2nd";
brokenTrace("1st", $arg2, "3th", "4th");
function backtraceWrapper(){
$bt = debug_backtrace();
var_dump($bt[1]['args']);
}
?>
--EXPECT--
array(4) {
[0]=>
string(3) "1st"
[1]=>
string(3) "2nd"
[2]=>
string(3) "3th"
[3]=>
string(3) "4th"
}
array(4) {
[0]=>
string(3) "1st"
[1]=>
string(3) "2nd"
[2]=>
string(3) "3th"
[3]=>
string(3) "4th"
}
string(3) "1st"
string(3) "2nd"
NULL
string(3) "4th"
array(4) {
[0]=>
string(3) "1st"
[1]=>
string(3) "2nd"
[2]=>
NULL
[3]=>
string(3) "4th"
}
array(4) {
[0]=>
NULL
[1]=>
string(3) "2nd"
[2]=>
NULL
[3]=>
string(3) "4th"
}
array(4) {
[0]=>
NULL
[1]=>
string(3) "2nd"
[2]=>
NULL
[3]=>
string(3) "4th"
}
array(4) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
[3]=>
string(3) "4th"
}
NULL
NULL
NULL
string(3) "4th"