com php-src: Fixed #70547 similar bug in func_get_args: Zend/tests/bug70547.phpt Zend/zend_builtin _functions.c

From: Date: Tue, 22 Sep 2015 05:58:42 +0000
Subject: com php-src: Fixed #70547 similar bug in func_get_args: Zend/tests/bug70547.phpt Zend/zend_builtin _functions.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89099@lists.php.net to get a copy of this message
Commit: 0f3ab1c2d03c27ebee0156cd8bfbb1c5721d9f32 Author: Xinchen Hui <laruence@gmail.com> Tue, 22 Sep 2015 13:58:42 +0800 Parents: b8ea991821753898ba30fa170b25eadd3fc703b2 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0f3ab1c2d03c27ebee0156cd8bfbb1c5721d9f32 Log: Fixed #70547 similar bug in func_get_args Bugs: https://bugs.php.net/70547 Changed paths: M Zend/tests/bug70547.phpt M Zend/zend_builtin_functions.c Diff: diff --git a/Zend/tests/bug70547.phpt b/Zend/tests/bug70547.phpt index 195495d..0b9daf8 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 b0e4f6a..3bdc94d 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); }

« previous php.cvs (#89099) next »