1
0
mirror of https://github.com/php/php-src.git synced 2026-04-03 06:02:23 +02:00

Fixed bug #70547 (unsetting function variables corrupts backtrace)

This commit is contained in:
Xinchen Hui
2015-09-22 11:59:35 +08:00
parent ed5a5bdff8
commit e1dcfd2cf9
3 changed files with 62 additions and 4 deletions

2
NEWS
View File

@@ -3,6 +3,8 @@ PHP NEWS
01 Oct 2015, PHP 7.0.0 RC 4
- Core:
. Fixed bug #70547 (unsetting function variables corrupts backtrace).
(Laruence)
. Fixed bug #70528 (assert() with instanceof adds apostrophes around class
name). (Laruence)
. Fixed bug #70481 (Memory leak in auto_global_copy_ctor() in ZTS build).

48
Zend/tests/bug70547.phpt Normal file
View File

@@ -0,0 +1,48 @@
--TEST--
Bug #70547 (unsetting function variables corrupts backtrace)
--FILE--
<?php
function brokenTrace($arg1, $arg2, $arg3){
backtraceWrapper();
unset($arg3);
backtraceWrapper();
unset($arg1);
backtraceWrapper();
unset($arg2);
backtraceWrapper();
}
brokenTrace("1st", "2nd", "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(3) {
[0]=>
string(3) "1st"
[1]=>
string(3) "2nd"
[2]=>
string(3) "4th"
}
array(2) {
[0]=>
string(3) "2nd"
[1]=>
string(3) "4th"
}
array(1) {
[0]=>
string(3) "4th"
}

View File

@@ -2233,8 +2233,12 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) /
if (ZEND_CALL_NUM_ARGS(call) > first_extra_arg) {
while (i < first_extra_arg) {
if (Z_OPT_REFCOUNTED_P(p)) Z_ADDREF_P(p);
ZEND_HASH_FILL_ADD(p);
if (Z_TYPE_INFO_P(p) != IS_UNDEF) {
if (Z_OPT_REFCOUNTED_P(p)) {
Z_ADDREF_P(p);
}
ZEND_HASH_FILL_ADD(p);
}
p++;
i++;
}
@@ -2243,8 +2247,12 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) /
}
while (i < num_args) {
if (Z_OPT_REFCOUNTED_P(p)) Z_ADDREF_P(p);
ZEND_HASH_FILL_ADD(p);
if (Z_TYPE_INFO_P(p) != IS_UNDEF) {
if (Z_OPT_REFCOUNTED_P(p)) {
Z_ADDREF_P(p);
}
ZEND_HASH_FILL_ADD(p);
}
p++;
i++;
}