diff options
author | Xinchen Hui <laruence@gmail.com> | 2015-09-23 10:00:20 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2015-09-23 10:00:20 +0800 |
commit | a9636ff5a254e0e054b55d328d6e370f34d71b0a (patch) | |
tree | d206b7078ee870c018ff711879f0c68f283b8f5a /Zend/zend_builtin_functions.c | |
parent | d82ea930edc7e0866814c6e36aa5c0fb3b36f7ec (diff) | |
download | php-git-a9636ff5a254e0e054b55d328d6e370f34d71b0a.tar.gz |
Fixed bug #70555 (fun_get_arg() on unsetted vars return UNKNOW)
and also keep the indices of func_get_args(). since they are similar
issue of #70574, thus reuse its test script.
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r-- | Zend/zend_builtin_functions.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 3bdc94d7d7..8ffdcaa0bc 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -471,8 +471,10 @@ ZEND_FUNCTION(func_get_arg) } else { arg = ZEND_CALL_ARG(ex, requested_offset + 1); } - ZVAL_DEREF(arg); - ZVAL_COPY(return_value, arg); + if (EXPECTED(!Z_ISUNDEF_P(arg))) { + ZVAL_DEREF(arg); + ZVAL_COPY(return_value, arg); + } } /* }}} */ @@ -482,7 +484,7 @@ ZEND_FUNCTION(func_get_args) { zval *p, *q; uint32_t arg_count, first_extra_arg; - uint32_t i; + uint32_t i, n; zend_execute_data *ex = EX(prev_execute_data); if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) { @@ -498,6 +500,7 @@ 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) { @@ -507,8 +510,9 @@ ZEND_FUNCTION(func_get_args) if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - ZEND_HASH_FILL_ADD(q); + n++; } + ZEND_HASH_FILL_ADD(q); p++; i++; } @@ -521,12 +525,14 @@ ZEND_FUNCTION(func_get_args) if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - ZEND_HASH_FILL_ADD(q); + n++; } + ZEND_HASH_FILL_ADD(q); p++; i++; } } ZEND_HASH_FILL_END(); + Z_ARRVAL_P(return_value)->nNumOfElements = n; } } /* }}} */ @@ -2232,6 +2238,7 @@ 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); @@ -2245,8 +2252,9 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (Z_OPT_REFCOUNTED_P(p)) { Z_ADDREF_P(p); } - ZEND_HASH_FILL_ADD(p); + n++; } + ZEND_HASH_FILL_ADD(p); p++; i++; } @@ -2259,12 +2267,14 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (Z_OPT_REFCOUNTED_P(p)) { Z_ADDREF_P(p); } - ZEND_HASH_FILL_ADD(p); + n++; } + ZEND_HASH_FILL_ADD(p); p++; i++; } } ZEND_HASH_FILL_END(); + Z_ARRVAL_P(arg_array)->nNumOfElements = n; } } /* }}} */ |