From bfaa9669a6bed7eeb45873ee568c0e8aa64e2409 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 5 Mar 2014 17:58:46 +0800 Subject: [PATCH] Fixed refcounted --- ext/standard/array.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ext/standard/array.c b/ext/standard/array.c index 98535e9fee..e59eb847fd 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1820,7 +1820,9 @@ PHPAPI HashTable* php_splice(HashTable *in_hash, int offset, int length, zval *l pos++; /* Get entry and increase reference count */ entry = &p->val; - Z_ADDREF_P(entry); + if (Z_REFCOUNTED_P(entry)) { + Z_ADDREF_P(entry); + } /* Update output hash depending on key type */ if (p->key == NULL) { @@ -1837,7 +1839,9 @@ PHPAPI HashTable* php_splice(HashTable *in_hash, int offset, int length, zval *l if (Z_TYPE(p->val) == IS_UNDEF) continue; pos++; entry = &p->val; - Z_ADDREF_P(entry); + if (Z_REFCOUNTED_P(entry)) { + Z_ADDREF_P(entry); + } if (p->key == NULL) { zend_hash_next_index_insert(removed, entry); } else { @@ -1863,7 +1867,9 @@ PHPAPI HashTable* php_splice(HashTable *in_hash, int offset, int length, zval *l p = in_hash->arData + idx; if (Z_TYPE(p->val) == IS_UNDEF) continue; entry = &p->val; - if (IS_REFCOUNTED(Z_TYPE_P(entry))) Z_ADDREF_P(entry); + if (Z_REFCOUNTED_P(entry)) { + Z_ADDREF_P(entry); + } if (p->key == NULL) { zend_hash_next_index_insert(out_hash, entry); } else { @@ -2288,7 +2294,9 @@ PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src TSRMLS_DC (dest_entry = zend_hash_find(dest, string_key)) == NULL || Z_TYPE_P(dest_entry) != IS_ARRAY) { - Z_ADDREF_P(src_entry); + if (Z_REFCOUNTED_P(src_entry)) { + Z_ADDREF_P(src_entry); + } zend_hash_update(dest, string_key, src_entry); continue; @@ -2300,7 +2308,9 @@ PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src TSRMLS_DC (dest_entry = zend_hash_index_find(dest, num_key)) == NULL || Z_TYPE_P(dest_entry) != IS_ARRAY) { - Z_ADDREF_P(src_entry); + if (Z_REFCOUNTED_P(src_entry)) { + Z_ADDREF_P(src_entry); + } zend_hash_index_update(dest, num_key, src_entry); continue; -- 2.40.0