summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-02-19 14:35:28 +0400
committerDmitry Stogov <dmitry@zend.com>2014-02-19 14:35:28 +0400
commit8bae1daa0c7f6b66283baedd5205906fc6357363 (patch)
tree7db3ada36331e5452aa8503b8156a205da9b845c /Zend/zend_builtin_functions.c
parent9067dbcd0d8d8bed6c723d274b162182f33281ea (diff)
downloadphp-git-8bae1daa0c7f6b66283baedd5205906fc6357363.tar.gz
Use better data structures (incomplete)
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 8daa7cdda4..13a3fb49bf 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -585,6 +585,9 @@ ZEND_FUNCTION(each)
return;
}
+ if (Z_TYPE_P(array) == IS_REFERENCE) {
+ array = Z_REFVAL_P(array);
+ }
target_hash = HASH_OF(array);
if (!target_hash) {
zend_error(E_WARNING,"Variable passed to each() is not an array or object");
@@ -603,9 +606,9 @@ ZEND_FUNCTION(each)
entry = &tmp;
}
zend_hash_index_update(Z_ARRVAL_P(return_value), 1, entry);
- Z_ADDREF_P(entry);
+ if (IS_REFCOUNTED(Z_TYPE_P(entry))) Z_ADDREF_P(entry);
zend_hash_str_update(Z_ARRVAL_P(return_value), "value", sizeof("value")-1, entry);
- Z_ADDREF_P(entry);
+ if (IS_REFCOUNTED(Z_TYPE_P(entry))) Z_ADDREF_P(entry);
/* add the key elements */
switch (zend_hash_get_current_key_ex(target_hash, &key, &num_key, 0, NULL)) {
@@ -617,7 +620,7 @@ ZEND_FUNCTION(each)
break;
}
zend_hash_str_update(Z_ARRVAL_P(return_value), "key", sizeof("key")-1, inserted_pointer);
- Z_ADDREF_P(inserted_pointer);
+ if (IS_REFCOUNTED(Z_TYPE_P(inserted_pointer))) Z_ADDREF_P(inserted_pointer);
zend_hash_move_forward(target_hash);
}
/* }}} */