com php-src: retval might be IS_UNDEF even the call i s successed: ext/standard/array.c
| From: | Dmitry Stogov | Date: | Wed, 05 Mar 2014 09:53:01 +0000 |
| Subject: | com php-src: retval might be IS_UNDEF even the call i s successed: ext/standard/array.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77746@lists.php.net to get a copy of this message | ||
Commit: 0791bdb562afe0e8864ef44bb0d085eabe1dce07
Author: Xinchen Hui <laruence@gmail.com> Wed, 5 Mar 2014 17:53:01 +0800
Parents: 75d567ef9a2a02e11bb64a73f928caaa52ca153c
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0791bdb562afe0e8864ef44bb0d085eabe1dce07
Log:
retval might be IS_UNDEF even the call is successed
Changed paths:
M ext/standard/array.c
Diff:
diff --git a/ext/standard/array.c b/ext/standard/array.c
index cad4cc8...98535e9 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -4178,7 +4178,6 @@ PHP_FUNCTION(array_filter)
zval *operand;
zval args[2];
zval retval;
-//??? zval *key = NULL;
zend_bool have_callback = 0;
long use_type = 0;
zend_string *string_key;
@@ -4200,16 +4199,7 @@ PHP_FUNCTION(array_filter)
have_callback = 1;
fci.no_separation = 0;
fci.retval = &retval;
-
- if (use_type == ARRAY_FILTER_USE_BOTH) {
- fci.param_count = 2;
-//??? args[1] = &key;
- } else {
- fci.param_count = 1;
- if (use_type == ARRAY_FILTER_USE_KEY) {
-//??? args[0] = &key;
- }
- }
+ fci.param_count = 1;
}
for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(array), &pos);
@@ -4223,28 +4213,40 @@ PHP_FUNCTION(array_filter)
/* Set up the key */
switch (key_type) {
case HASH_KEY_IS_LONG:
- ZVAL_LONG(&args[0], num_key);
+ if (use_type == ARRAY_FILTER_USE_BOTH) {
+ fci.param_count = 2;
+ ZVAL_LONG(&args[1], num_key);
+ } else if (use_type == ARRAY_FILTER_USE_KEY) {
+ ZVAL_LONG(&args[0], num_key);
+ }
break;
case HASH_KEY_IS_STRING:
- ZVAL_STR(&args[0], STR_COPY(string_key));
+ if (use_type == ARRAY_FILTER_USE_BOTH) {
+ ZVAL_STR(&args[1], STR_COPY(string_key));
+ } else if (use_type == ARRAY_FILTER_USE_KEY) {
+ ZVAL_STR(&args[0], STR_COPY(string_key));
+ }
break;
}
}
-
if (use_type != ARRAY_FILTER_USE_KEY) {
ZVAL_COPY_VALUE(&args[0], operand);
}
fci.params = args;
- if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && Z_TYPE(retval)
!= IS_UNDEF) {
- int retval_true = zend_is_true(&retval TSRMLS_CC);
+ if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS) {
+ if (!ZVAL_IS_UNDEF(&retval)) {
+ int retval_true = zend_is_true(&retval TSRMLS_CC);
- zval_ptr_dtor(&retval);
- if (use_type) {
- zval_ptr_dtor(&args[0]);
- }
- if (!retval_true) {
+ zval_ptr_dtor(&retval);
+ if (use_type) {
+ zval_ptr_dtor(&args[0]);
+ }
+ if (!retval_true) {
+ continue;
+ }
+ } else {
continue;
}
} else {