Skip to content

Commit 6641e3b

Browse files
committed
Fix bug #81630: Don't claim known hash in getTraitAliases()
We don't intern this string, and this code is not particularly performance critical in the first place, so just drop the the assumption.
1 parent d0ecc83 commit 6641e3b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ PHP NEWS
99
- Reflection:
1010
. Fixed bug #81611 (ArgumentCountError when getting default value from
1111
ReflectionParameter with new). (Cameron Porter)
12+
. Fixed bug #81630 (PHP 8.1: ReflectionClass->getTraitAliases() crashes with
13+
Internal error). (Nikita)
1214

1315
- XML:
1416
. Fixed bug #79971 (special character is breaking the path in xml function).

ext/reflection/php_reflection.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5116,18 +5116,15 @@ ZEND_METHOD(ReflectionClass, getTraitAliases)
51165116

51175117
if (!class_name) {
51185118
uint32_t j = 0;
5119-
zval *zv;
5120-
zend_class_entry *trait;
51215119
zend_string *lcname = zend_string_tolower(cur_ref->method_name);
51225120

51235121
for (j = 0; j < ce->num_traits; j++) {
5124-
zv = zend_hash_find_known_hash(CG(class_table), ce->trait_names[j].lc_name);
5125-
if (zv) {
5126-
trait = Z_CE_P(zv);
5127-
if (zend_hash_exists(&trait->function_table, lcname)) {
5128-
class_name = trait->name;
5129-
break;
5130-
}
5122+
zend_class_entry *trait =
5123+
zend_hash_find_ptr(CG(class_table), ce->trait_names[j].lc_name);
5124+
ZEND_ASSERT(trait && "Trait must exist");
5125+
if (zend_hash_exists(&trait->function_table, lcname)) {
5126+
class_name = trait->name;
5127+
break;
51315128
}
51325129
}
51335130
zend_string_release_ex(lcname, 0);

0 commit comments

Comments
 (0)