com php-src: Fixed bug #70398 (SIGSEGV, Segmentation fault zend_ast_destroy_ex): NEWS Zend/tests/bug70 398.phpt Zend/zend_builtin_functions.c
| From: | Xinchen Hui | Date: | Thu, 03 Sep 2015 05:07:29 +0000 |
| Subject: | com php-src: Fixed bug #70398 (SIGSEGV, Segmentation fault zend_ast_destroy_ex): NEWS Zend/tests/bug70 398.phpt Zend/zend_builtin_functions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88885@lists.php.net to get a copy of this message | ||
Commit: 6815c08e2939f49a2ac9087924d58448edb401ba
Author: Xinchen Hui <laruence@gmail.com> Wed, 2 Sep 2015 22:07:29 -0700
Parents: 6290344d96bc31a5c4f682ac5d94d9f30c01d4df
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6815c08e2939f49a2ac9087924d58448edb401ba
Log:
Fixed bug #70398 (SIGSEGV, Segmentation fault zend_ast_destroy_ex)
Bugs:
https://bugs.php.net/70398
Changed paths:
M NEWS
A Zend/tests/bug70398.phpt
M Zend/zend_builtin_functions.c
Diff:
diff --git a/NEWS b/NEWS
index 8d5a381...8c5b74e 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP NEWS
03 Sep 2015, PHP 7.0.0 RC 2
- Core:
+ . Fixed bug #70398 (SIGSEGV, Segmentation fault zend_ast_destroy_ex)
+ (Dmitry, Bob, Laruence)
. Fixed bug #70332 (Wrong behavior while returning reference on object).
(Laruence, Dmitry)
. Fixed bug #70300 (Syntactical inconsistency with new group use syntax).
diff --git a/Zend/tests/bug70398.phpt b/Zend/tests/bug70398.phpt
new file mode 100644
index 0000000..8c0b1ab
--- /dev/null
+++ b/Zend/tests/bug70398.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #70398 (SIGSEGV, Segmentation fault zend_ast_destroy_ex)
+--FILE--
+<?php
+
+define("FILE_STREAM", fopen("php://temp", "r"));
+
+
+$array = array(
+ fopen("php://temp", "r"),
+);
+
+define("FILE_STREAMS", $array);
+?>
+OK
+--EXPECT--
+OK
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index fc834df..818cc54 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -780,6 +780,8 @@ 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);
}
@@ -810,7 +812,7 @@ ZEND_FUNCTION(define)
ZEND_PARSE_PARAMETERS_END();
#endif
- if(non_cs) {
+ if (non_cs) {
case_sensitive = 0;
}
@@ -829,9 +831,14 @@ repeat:
case IS_STRING:
case IS_FALSE:
case IS_TRUE:
- case IS_RESOURCE:
case IS_NULL:
break;
+ case IS_RESOURCE:
+ ZVAL_COPY(&val_free, val);
+ /* TODO: better solution than this tricky disable dtor on resource? */
+ Z_TYPE_INFO(val_free) &= ~(IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT);
+ val = &val_free;
+ break;
case IS_ARRAY:
if (!Z_IMMUTABLE_P(val)) {
if (!validate_constant_array(Z_ARRVAL_P(val))) {