diff --git a/Zend/tests/bug70547.phpt b/Zend/tests/bug70547.phpt index 1b4c35d65fd..f793e70781c 100644 --- a/Zend/tests/bug70547.phpt +++ b/Zend/tests/bug70547.phpt @@ -53,27 +53,43 @@ string(3) "1st" string(3) "2nd" NULL string(3) "4th" -array(3) { +array(4) { [0]=> string(3) "1st" [1]=> &string(3) "2nd" + [2]=> + NULL [3]=> string(3) "4th" } -array(2) { +array(4) { + [0]=> + NULL [1]=> string(3) "2nd" + [2]=> + NULL [3]=> string(3) "4th" } -array(2) { +array(4) { + [0]=> + NULL [1]=> &string(3) "2nd" + [2]=> + NULL [3]=> string(3) "4th" } -array(1) { +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL [3]=> string(3) "4th" } diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 3b04ead9554..a429ca013aa 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -507,7 +507,7 @@ ZEND_FUNCTION(func_get_args) { zval *p, *q; uint32_t arg_count, first_extra_arg; - uint32_t i, n; + uint32_t i; zend_execute_data *ex = EX(prev_execute_data); if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) { @@ -523,7 +523,6 @@ ZEND_FUNCTION(func_get_args) zend_hash_real_init(Z_ARRVAL_P(return_value), 1); ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) { i = 0; - n = 0; p = ZEND_CALL_ARG(ex, 1); if (arg_count > first_extra_arg) { while (i < first_extra_arg) { @@ -533,7 +532,8 @@ ZEND_FUNCTION(func_get_args) if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; @@ -548,14 +548,15 @@ ZEND_FUNCTION(func_get_args) if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; i++; } } ZEND_HASH_FILL_END(); - Z_ARRVAL_P(return_value)->nNumOfElements = n; + Z_ARRVAL_P(return_value)->nNumOfElements = arg_count; } } /* }}} */ @@ -2219,7 +2220,6 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / array_init_size(arg_array, num_args); if (num_args) { uint32_t i = 0; - uint32_t n = 0; zval *p = ZEND_CALL_ARG(call, 1); zend_hash_real_init(Z_ARRVAL_P(arg_array), 1); @@ -2242,12 +2242,9 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); } - n++; ZEND_HASH_FILL_ADD(arg); } else { - zval tmp; - ZVAL_UNDEF(&tmp); - ZEND_HASH_FILL_ADD(&tmp); + ZEND_HASH_FILL_ADD(&EG(uninitialized_zval)); } i++; } @@ -2257,9 +2254,10 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (Z_OPT_REFCOUNTED_P(p)) { Z_ADDREF_P(p); } - n++; + ZEND_HASH_FILL_ADD(p); + } else { + ZEND_HASH_FILL_ADD(&EG(uninitialized_zval)); } - ZEND_HASH_FILL_ADD(p); p++; i++; } @@ -2272,14 +2270,15 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (Z_OPT_REFCOUNTED_P(p)) { Z_ADDREF_P(p); } - n++; + ZEND_HASH_FILL_ADD(p); + } else { + ZEND_HASH_FILL_ADD(&EG(uninitialized_zval)); } - ZEND_HASH_FILL_ADD(p); p++; i++; } } ZEND_HASH_FILL_END(); - Z_ARRVAL_P(arg_array)->nNumOfElements = n; + Z_ARRVAL_P(arg_array)->nNumOfElements = num_args; } } /* }}} */