diff options
| -rw-r--r-- | Zend/tests/bug70547.phpt | 53 | ||||
| -rw-r--r-- | Zend/zend_builtin_functions.c | 24 |
2 files changed, 59 insertions, 18 deletions
diff --git a/Zend/tests/bug70547.phpt b/Zend/tests/bug70547.phpt index 195495dcdc..0b9daf869d 100644 --- a/Zend/tests/bug70547.phpt +++ b/Zend/tests/bug70547.phpt @@ -2,19 +2,24 @@ Bug #70547 (unsetting function variables corrupts backtrace) --FILE-- <?php -function brokenTrace($arg1, $arg2, $arg3){ - backtraceWrapper(); +function brokenTrace($arg1, &$arg2, $arg3){ + backtraceWrapper(); + var_dump(func_get_args()); unset($arg3); - backtraceWrapper(); - unset($arg1); - backtraceWrapper(); - unset($arg2); - backtraceWrapper(); + backtraceWrapper(); + var_dump(func_get_args()); + unset($arg1); + backtraceWrapper(); + var_dump(func_get_args()); + unset($arg2); + backtraceWrapper(); + var_dump(func_get_args()); } -brokenTrace("1st", "2nd", "3th", "4th"); +$arg2 = "2nd"; +brokenTrace("1st", $arg2, "3th", "4th"); function backtraceWrapper(){ - $bt = debug_backtrace(); - var_dump($bt[1]['args']); + $bt = debug_backtrace(); + var_dump($bt[1]['args']); } ?> --EXPECT-- @@ -22,6 +27,16 @@ 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" @@ -32,12 +47,26 @@ array(3) { [0]=> string(3) "1st" [1]=> + &string(3) "2nd" + [2]=> + 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(2) { + [0]=> string(3) "2nd" [1]=> string(3) "4th" @@ -46,3 +75,7 @@ array(1) { [0]=> string(3) "4th" } +array(1) { + [0]=> + string(3) "4th" +} diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index b0e4f6ab02..3bdc94d7d7 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -502,9 +502,13 @@ ZEND_FUNCTION(func_get_args) if (arg_count > first_extra_arg) { while (i < first_extra_arg) { q = p; - ZVAL_DEREF(q); - if (Z_OPT_REFCOUNTED_P(q)) Z_ADDREF_P(q); - ZEND_HASH_FILL_ADD(q); + if (EXPECTED(Z_TYPE_INFO_P(q) != IS_UNDEF)) { + ZVAL_DEREF(q); + if (Z_OPT_REFCOUNTED_P(q)) { + Z_ADDREF_P(q); + } + ZEND_HASH_FILL_ADD(q); + } p++; i++; } @@ -512,9 +516,13 @@ ZEND_FUNCTION(func_get_args) } while (i < arg_count) { q = p; - ZVAL_DEREF(q); - if (Z_OPT_REFCOUNTED_P(q)) Z_ADDREF_P(q); - ZEND_HASH_FILL_ADD(q); + if (EXPECTED(Z_TYPE_INFO_P(q) != IS_UNDEF)) { + ZVAL_DEREF(q); + if (Z_OPT_REFCOUNTED_P(q)) { + Z_ADDREF_P(q); + } + ZEND_HASH_FILL_ADD(q); + } p++; i++; } @@ -2233,7 +2241,7 @@ 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_TYPE_INFO_P(p) != IS_UNDEF) { + if (EXPECTED(Z_TYPE_INFO_P(p) != IS_UNDEF)) { if (Z_OPT_REFCOUNTED_P(p)) { Z_ADDREF_P(p); } @@ -2247,7 +2255,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / } while (i < num_args) { - if (Z_TYPE_INFO_P(p) != IS_UNDEF) { + if (EXPECTED(Z_TYPE_INFO_P(p) != IS_UNDEF)) { if (Z_OPT_REFCOUNTED_P(p)) { Z_ADDREF_P(p); } |
