summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-11-07 20:23:30 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-11-07 20:23:30 +0000
commitcb96148912594f29c23883b3bea5090af0c74443 (patch)
tree9d20d1e9e55f788b9049b664b7b75bfbc2e36124
parent887b3484f7797667293deef083eacee76270aabe (diff)
downloadphp-git-cb96148912594f29c23883b3bea5090af0c74443.tar.gz
Fixed bug #33282 (Re-assignment by reference does not clear the is_ref flag)
# Original patch by Matt Wilmas
-rw-r--r--Zend/tests/bug33282.phpt19
-rw-r--r--Zend/zend_execute.c6
2 files changed, 20 insertions, 5 deletions
diff --git a/Zend/tests/bug33282.phpt b/Zend/tests/bug33282.phpt
new file mode 100644
index 0000000000..65e3c16cf5
--- /dev/null
+++ b/Zend/tests/bug33282.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #33282 (Re-assignment by reference does not clear the is_ref flag)
+--FILE--
+<?php
+ $a = array(1, 2, 3);
+ $r = &$a[0];
+ $r = &$a[1];
+ $r = &$a[2];
+ var_dump($a);
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ &int(3)
+}
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index fbaed013b1..c6ab1db9b9 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -411,11 +411,7 @@ static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **va
*variable_ptr_ptr = value_ptr;
value_ptr->refcount++;
- variable_ptr->refcount--;
- if (variable_ptr->refcount==0) {
- zendi_zval_dtor(*variable_ptr);
- FREE_ZVAL(variable_ptr);
- }
+ zval_ptr_dtor(&variable_ptr);
} else if (!variable_ptr->is_ref) {
if (variable_ptr_ptr == value_ptr_ptr) {
SEPARATE_ZVAL(variable_ptr_ptr);