Skip to content

Commit d2514e3

Browse files
authored
Simplify SimpleXML code for checking if count() is overridden by a userland class (#18722)
1 parent 02ebda5 commit d2514e3

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

ext/simplexml/simplexml.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,27 +2156,14 @@ static void sxe_object_free_storage(zend_object *object)
21562156
/* {{{ php_sxe_find_fptr_count() */
21572157
static zend_function* php_sxe_find_fptr_count(zend_class_entry *ce)
21582158
{
2159-
zend_function *fptr_count = NULL;
2160-
zend_class_entry *parent = ce;
2161-
int inherited = 0;
2162-
2163-
while (parent) {
2164-
if (parent == ce_SimpleXMLElement) {
2165-
break;
2159+
if (ce->type == ZEND_USER_CLASS) {
2160+
zend_function *fptr_count = zend_hash_find_ptr(&ce->function_table, ZSTR_KNOWN(ZEND_STR_COUNT));
2161+
if (fptr_count->common.scope != ce_SimpleXMLElement) {
2162+
return fptr_count;
21662163
}
2167-
parent = parent->parent;
2168-
inherited = 1;
21692164
}
21702165

2171-
if (inherited) {
2172-
/* Find count() method */
2173-
fptr_count = zend_hash_find_ptr(&ce->function_table, ZSTR_KNOWN(ZEND_STR_COUNT));
2174-
if (fptr_count->common.scope == parent) {
2175-
fptr_count = NULL;
2176-
}
2177-
}
2178-
2179-
return fptr_count;
2166+
return NULL;
21802167
}
21812168
/* }}} */
21822169

0 commit comments

Comments
 (0)