com php-src: Add test script and use efree_size: Zend/tes ts/foreach_reference.phpt Zend/zend_variables.c
| From: | Xinchen Hui | Date: | Mon, 05 Jan 2015 14:21:37 +0000 |
| Subject: | com php-src: Add test script and use efree_size: Zend/tes ts/foreach_reference.phpt Zend/zend_variables.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-83992@lists.php.net to get a copy of this message | ||
Commit: faa41715071966de6d0b56977eaf4c51831c00ee
Author: Xinchen Hui <laruence@php.net> Mon, 5 Jan 2015 22:20:13 +0800
Parents: 40230eef81c7331468324cebe7b39cdbff7d470c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=faa41715071966de6d0b56977eaf4c51831c00ee
Log:
Add test script and use efree_size
Changed paths:
A Zend/tests/foreach_reference.phpt
M Zend/zend_variables.c
Diff:
diff --git a/Zend/tests/foreach_reference.phpt b/Zend/tests/foreach_reference.phpt
new file mode 100644
index 0000000..6b27320
--- /dev/null
+++ b/Zend/tests/foreach_reference.phpt
@@ -0,0 +1,50 @@
+--TEST--
+foreach with reference
+--FILE--
+<?php
+
+$array = ['a', 'b', 'c', 'd'];
+
+foreach ($array as &$a) {
+}
+
+var_dump($array);
+
+var_dump(array_values($array));
+var_dump($a);
+
+var_dump(array_reverse($array));
+
+?>
+--EXPECTF--
+array(4) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "c"
+ [3]=>
+ &string(1) "d"
+}
+array(4) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "c"
+ [3]=>
+ &string(1) "d"
+}
+string(1) "d"
+array(4) {
+ [0]=>
+ &string(1) "d"
+ [1]=>
+ string(1) "c"
+ [2]=>
+ string(1) "b"
+ [3]=>
+ string(1) "a"
+}
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index b476bd9..91d68c3 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -207,7 +207,7 @@ ZEND_API void zval_add_ref(zval *p)
if (Z_ISREF_P(p) && Z_REFCOUNT_P(p) == 1) {
zend_reference *ref = Z_REF_P(p);
ZVAL_COPY(p, Z_REFVAL_P(p));
- efree(ref);
+ efree_size(ref, sizeof(zend_reference));
} else {
Z_ADDREF_P(p);
}