Created
June 30, 2014 19:03
-
-
Save dstogov/b73884e252b376957ebc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c | |
index ad92c5f..6ada04e 100644 | |
--- a/Zend/zend_execute.c | |
+++ b/Zend/zend_execute.c | |
@@ -943,6 +943,26 @@ copy_value: | |
} | |
} | |
+static void zval_deep_copy(zval **p) | |
+{ | |
+ zval *value; | |
+ | |
+ ALLOC_ZVAL(value); | |
+ *value = **p; | |
+ if (Z_TYPE_P(value) == IS_ARRAY) { | |
+ HashTable *ht; | |
+ | |
+ ALLOC_HASHTABLE(ht); | |
+ zend_hash_init(ht, zend_hash_num_elements(Z_ARRVAL_P(value)), NULL, ZVAL_PTR_DTOR, 0); | |
+ zend_hash_copy(ht, Z_ARRVAL_P(value), (copy_ctor_func_t) zval_deep_copy, NULL, sizeof(zval *)); | |
+ Z_ARRVAL_P(value) = ht; | |
+ } else { | |
+ zval_copy_ctor(value); | |
+ } | |
+ INIT_PZVAL(value); | |
+ *p = value; | |
+} | |
+ | |
/* Utility Functions for Extensions */ | |
static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC) | |
{ | |
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h | |
index cd7dbf4..c3fb86d 100644 | |
--- a/Zend/zend_vm_def.h | |
+++ b/Zend/zend_vm_def.h | |
@@ -3422,6 +3422,13 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST) | |
if (IS_CONSTANT_TYPE(Z_TYPE_P(assignment_value))) { | |
Z_SET_REFCOUNT_P(assignment_value, 1); | |
zval_update_constant(&assignment_value, 0 TSRMLS_CC); | |
+ } else if (Z_TYPE_P(assignment_value) == IS_ARRAY) { | |
+ HashTable *ht; | |
+ | |
+ ALLOC_HASHTABLE(ht); | |
+ zend_hash_init(ht, zend_hash_num_elements(Z_ARRVAL_P(assignment_value)), NULL, ZVAL_PTR_DTOR, 0); | |
+ zend_hash_copy(ht, Z_ARRVAL_P(assignment_value), (copy_ctor_func_t) zval_deep_copy, NULL, sizeof(zval *)); | |
+ Z_ARRVAL_P(assignment_value) = ht; | |
} else { | |
zval_copy_ctor(assignment_value); | |
} | |
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h | |
index 29a8c0c..3fa94d1 100644 | |
--- a/Zend/zend_vm_execute.h | |
+++ b/Zend/zend_vm_execute.h | |
@@ -1624,6 +1624,13 @@ static int ZEND_FASTCALL ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ | |
if (IS_CONSTANT_TYPE(Z_TYPE_P(assignment_value))) { | |
Z_SET_REFCOUNT_P(assignment_value, 1); | |
zval_update_constant(&assignment_value, 0 TSRMLS_CC); | |
+ } else if (Z_TYPE_P(assignment_value) == IS_ARRAY) { | |
+ HashTable *ht; | |
+ | |
+ ALLOC_HASHTABLE(ht); | |
+ zend_hash_init(ht, zend_hash_num_elements(Z_ARRVAL_P(assignment_value)), NULL, ZVAL_PTR_DTOR, 0); | |
+ zend_hash_copy(ht, Z_ARRVAL_P(assignment_value), (copy_ctor_func_t) zval_deep_copy, NULL, sizeof(zval *)); | |
+ Z_ARRVAL_P(assignment_value) = ht; | |
} else { | |
zval_copy_ctor(assignment_value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment