diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 37a4ed46b4b61..db1d002b66979 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2156,27 +2156,14 @@ static void sxe_object_free_storage(zend_object *object) /* {{{ php_sxe_find_fptr_count() */ static zend_function* php_sxe_find_fptr_count(zend_class_entry *ce) { - zend_function *fptr_count = NULL; - zend_class_entry *parent = ce; - int inherited = 0; - - while (parent) { - if (parent == ce_SimpleXMLElement) { - break; + if (ce->type == ZEND_USER_CLASS) { + zend_function *fptr_count = zend_hash_find_ptr(&ce->function_table, ZSTR_KNOWN(ZEND_STR_COUNT)); + if (fptr_count->common.scope != ce_SimpleXMLElement) { + return fptr_count; } - parent = parent->parent; - inherited = 1; } - if (inherited) { - /* Find count() method */ - fptr_count = zend_hash_find_ptr(&ce->function_table, ZSTR_KNOWN(ZEND_STR_COUNT)); - if (fptr_count->common.scope == parent) { - fptr_count = NULL; - } - } - - return fptr_count; + return NULL; } /* }}} */