1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.1' into PHP-8.2

* PHP-8.1:
  Fix GH-10914: OPCache with Enum and Callback functions results in segmentation fault
This commit is contained in:
Niels Dossche
2023-07-11 17:40:21 +02:00
4 changed files with 37 additions and 2 deletions

4
NEWS
View File

@@ -44,6 +44,10 @@ PHP NEWS
. Fix GH-11300 (license issue: restricted unicode license headers).
(nielsdos)
- Opcache:
. Fixed bug GH-10914 (OPCache with Enum and Callback functions results in
segmentation fault). (nielsdos)
- PCNTL:
. Fixed bug GH-11498 (SIGCHLD is not always returned from proc_open).
(nielsdos)

View File

@@ -0,0 +1,26 @@
--TEST--
GH-10914 (OPCache with Enum and Callback functions results in segmentation fault)
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.protect_memory=1
opcache.preload={PWD}/preload_gh10914.inc
--EXTENSIONS--
opcache
--SKIPIF--
<?php
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
?>
--FILE--
<?php
$x = new ReflectionEnum(ExampleEnum::class);
var_dump($x->getCases()[0]->getValue());
var_dump($x->getCases()[0]->getBackingValue());
var_dump($x->getCase('FIRST')->getValue());
var_dump($x->getCase('FIRST')->getBackingValue());
?>
--EXPECT--
enum(ExampleEnum::FIRST)
string(4) "AAAb"
enum(ExampleEnum::FIRST)
string(4) "AAAb"

View File

@@ -0,0 +1,5 @@
<?php
enum ExampleEnum: string
{
case FIRST = "AAA"."b";
}

View File

@@ -6863,7 +6863,7 @@ ZEND_METHOD(ReflectionEnum, getCase)
GET_REFLECTION_OBJECT_PTR(ce);
zend_class_constant *constant = zend_hash_find_ptr(&ce->constants_table, name);
zend_class_constant *constant = zend_hash_find_ptr(CE_CONSTANTS_TABLE(ce), name);
if (constant == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Case %s::%s does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name));
RETURN_THROWS();
@@ -6890,7 +6890,7 @@ ZEND_METHOD(ReflectionEnum, getCases)
GET_REFLECTION_OBJECT_PTR(ce);
array_init(return_value);
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&ce->constants_table, name, constant) {
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(CE_CONSTANTS_TABLE(ce), name, constant) {
if (ZEND_CLASS_CONST_FLAGS(constant) & ZEND_CLASS_CONST_IS_CASE) {
zval class_const;
reflection_enum_case_factory(ce, name, constant, &class_const);