com php-src: We should keep one refcount to resource: Zend/tests/bug70398.phpt Zend/zend_builtin_functions.c
| From: | Xinchen Hui | Date: | Thu, 03 Sep 2015 05:14:48 +0000 |
| Subject: | com php-src: We should keep one refcount to resource: Zend/tests/bug70398.phpt Zend/zend_builtin_functions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88887@lists.php.net to get a copy of this message | ||
Commit: d5b78cec641173f3e37b9bad1e575fb5b646196c
Author: Xinchen Hui <laruence@gmail.com> Wed, 2 Sep 2015 22:14:48 -0700
Parents: 6815c08e2939f49a2ac9087924d58448edb401ba
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d5b78cec641173f3e37b9bad1e575fb5b646196c
Log:
We should keep one refcount to resource
Changed paths:
M Zend/tests/bug70398.phpt
M Zend/zend_builtin_functions.c
Diff:
diff --git a/Zend/tests/bug70398.phpt b/Zend/tests/bug70398.phpt
index 8c0b1ab..6f7b6f3 100644
--- a/Zend/tests/bug70398.phpt
+++ b/Zend/tests/bug70398.phpt
@@ -5,13 +5,14 @@ Bug #70398 (SIGSEGV, Segmentation fault zend_ast_destroy_ex)
define("FILE_STREAM", fopen("php://temp", "r"));
+define("FILE_STREAMS", array(fopen("php://temp", "r")));
-$array = array(
- fopen("php://temp", "r"),
-);
-
-define("FILE_STREAMS", $array);
+var_dump(FILE_STREAM);
+var_dump(FILE_STREAMS);
?>
-OK
---EXPECT--
-OK
+--EXPECTF--
+resource(%d) of type (stream)
+array(1) {
+ [0]=>
+ resource(%d) of type (stream)
+}
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 818cc54..e3f087b 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -780,10 +780,11 @@ static void copy_constant_array(zval *dst, zval *src) /* {{{ */
if (!Z_IMMUTABLE_P(val)) {
copy_constant_array(new_val, val);
}
- } else if (Z_TYPE_INFO_P(val) == IS_RESOURCE_EX) {
- Z_TYPE_INFO_P(new_val) &= ~(IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT);
} else if (Z_REFCOUNTED_P(val)) {
Z_ADDREF_P(val);
+ if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_RESOURCE_EX)) {
+ Z_TYPE_INFO_P(new_val) &= ~(IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT);
+ }
}
} ZEND_HASH_FOREACH_END();
}