diff --git a/NEWS b/NEWS index 3d8abc9d9a6..dec9a664e8c 100644 --- a/NEWS +++ b/NEWS @@ -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). diff --git a/Zend/tests/bug70547.phpt b/Zend/tests/bug70547.phpt new file mode 100644 index 00000000000..195495dcdc0 --- /dev/null +++ b/Zend/tests/bug70547.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #70547 (unsetting function variables corrupts backtrace) +--FILE-- + +--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" +} diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index e3f087b356c..b0e4f6ab021 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -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++; }