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

Merge branch 'PHP-8.3'

* PHP-8.3:
  Fix use-after-free of constant name
This commit is contained in:
Ilija Tovilo
2023-10-11 11:52:21 +02:00
3 changed files with 25 additions and 0 deletions

7
Zend/tests/gh12366.inc Normal file
View File

@@ -0,0 +1,7 @@
<?php
enum Level: int {
case Debug = 100;
}
var_dump(Level::Debug);

16
Zend/tests/gh12366.phpt Normal file
View File

@@ -0,0 +1,16 @@
--TEST--
GH-12366: Use-after-free of constant name when script doesn't fit in SHM
--EXTENSIONS--
opcache
--INI--
opcache.enable_cli=1
opcache.file_update_protection=1
--FILE--
<?php
$file = __DIR__ . '/gh12366.inc';
// Update timestamp and use opcache.file_update_protection=1 to prevent included file from being persisted in shm.
touch($file);
require $file;
?>
--EXPECT--
enum(Level::Debug)

View File

@@ -236,6 +236,7 @@ zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce)
ZSTR_VAL(name));
goto failure;
}
Z_TRY_ADDREF_P(case_name);
zend_hash_index_add_new(backed_enum_table, long_key, case_name);
} else {
ZEND_ASSERT(ce->enum_backing_type == IS_STRING);
@@ -248,6 +249,7 @@ zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce)
ZSTR_VAL(name));
goto failure;
}
Z_TRY_ADDREF_P(case_name);
zend_hash_add_new(backed_enum_table, string_key, case_name);
}
} ZEND_HASH_FOREACH_END();