com php-src: Fixed bug #77664 (Segmentation fault when using undefined constant in custom wrapper): NEWS ext/standard/tests/streams/bug77664.phpt
main/streams/userspace.c
| From: | Xinchen Hui | Date: | Mon, 25 Feb 2019 06:41:46 +0000 |
| Subject: | com php-src: Fixed bug #77664 (Segmentation fault when using undefined constant in custom wrapper): NEWS ext/standard/tests/streams/bug77664.phpt main/streams/userspace.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104850@lists.php.net to get a copy of this message | ||
Commit: 4a72dd782df3089a0d944a7e51eabebdf1f1abc3
Author: Xinchen Hui <laruence@gmail.com> Mon, 25 Feb 2019 14:40:53 +0800
Parents: 01c00953ff07b3b9414c446c6872b047b23afe24
Branches: PHP-7.2 PHP-7.3 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4a72dd782df3089a0d944a7e51eabebdf1f1abc3
Log:
Fixed bug #77664 (Segmentation fault when using undefined constant in custom wrapper)
Bugs:
https://bugs.php.net/77664
Changed paths:
M NEWS
A ext/standard/tests/streams/bug77664.phpt
M main/streams/userspace.c
Diff:
diff --git a/NEWS b/NEWS
index 4dac16a..37138ed 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug #77652 (Anonymous classes can lose their interface information).
(Nikita)
+- Standard:
+ . Fixed bug #77664 (Segmentation fault when using undefined constant in
+ custom wrapper). (Laruence)
+
- MySQLi:
. Fixed bug #77597 (mysqli_fetch_field hangs scripts). (Nikita)
diff --git a/ext/standard/tests/streams/bug77664.phpt b/ext/standard/tests/streams/bug77664.phpt
new file mode 100644
index 0000000..6a92541
--- /dev/null
+++ b/ext/standard/tests/streams/bug77664.phpt
@@ -0,0 +1,19 @@
+--TEST--
+BUG #77664 (Segmentation fault when using undefined constant in custom wrapper)
+--FILE--
+<?php
+class ErrorWrapper {
+ public $context;
+ public $var = self::INVALID;
+}
+stream_wrapper_register('error',ErrorWrapper::class);
+file_get_contents('error://test');
+?>
+--EXPECTF--
+Warning: file_get_contents(error://test): failed to open stream: operation failed in %sbug77664.php
on line %d
+
+Fatal error: Uncaught Error: Undefined class constant 'self::INVALID' in
%sbug77664.php:%d
+Stack trace:
+#0 %sbug77664.php(%d): file_get_contents('error://test')
+#1 {main}
+ thrown in %sbug77664.php on line %d
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index c72c776..4925e41 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -289,7 +289,10 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap,
php
}
/* create an instance of our class */
- object_init_ex(object, uwrap->ce);
+ if (object_init_ex(object, uwrap->ce) == FAILURE) {
+ ZVAL_UNDEF(object);
+ return;
+ }
if (context) {
add_property_resource(object, "context", context->res);