From ed5b6af8af6a0b8c331e692cd0a81daeef59dcff Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 7 May 2014 16:52:58 +0800 Subject: Refactored filter --- main/php_variables.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'main/php_variables.c') diff --git a/main/php_variables.c b/main/php_variables.c index 547dbd5582..c67642c76f 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -635,13 +635,14 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC) if (Z_TYPE_P(src_entry) != IS_ARRAY || (key_type == HASH_KEY_IS_STRING && (dest_entry = zend_hash_find(dest, string_key)) == NULL) || (key_type == HASH_KEY_IS_LONG && (dest_entry = zend_hash_index_find(dest, num_key)) == NULL) - || Z_TYPE_P(dest_entry) != IS_ARRAY - ) { - Z_ADDREF_P(src_entry); + || Z_TYPE_P(dest_entry) != IS_ARRAY) { + if (Z_REFCOUNTED_P(src_entry)) { + Z_ADDREF_P(src_entry); + } if (key_type == HASH_KEY_IS_STRING) { if (!globals_check || string_key->len != sizeof("GLOBALS") || memcmp(string_key->val, "GLOBALS", sizeof("GLOBALS") - 1)) { zend_hash_update(dest, string_key, src_entry); - } else { + } else if (Z_REFCOUNTED_P(src_entry)) { Z_DELREF_P(src_entry); } } else { -- cgit v1.2.1