@@ -6655,6 +6655,7 @@ ZEND_METHOD(ReflectionAttribute, newInstance)
6655
6655
attribute_reference * attr ;
6656
6656
6657
6657
zend_class_entry * ce ;
6658
+ zend_string * lcname ;
6658
6659
zval obj ;
6659
6660
6660
6661
zval * args = NULL ;
@@ -6672,23 +6673,23 @@ ZEND_METHOD(ReflectionAttribute, newInstance)
6672
6673
RETURN_THROWS ();
6673
6674
}
6674
6675
6675
- if (SUCCESS != object_init_ex (& obj , ce )) {
6676
- RETURN_THROWS ();
6677
- }
6678
-
6679
- zend_string * lower_name = zend_string_tolower_ex (ce -> name , 1 );
6676
+ lcname = zend_string_tolower (ce -> name );
6680
6677
6681
- if (ce -> type == ZEND_USER_CLASS && ce -> info .user .attributes && zend_hash_str_exists (ce -> info .user .attributes , "phpattribute" , sizeof ("phpattribute" )- 1 ) == 0 ) {
6682
- zend_string_release (lower_name );
6678
+ if (ce -> type == ZEND_USER_CLASS && (! ce -> info .user .attributes || ! zend_hash_str_exists (ce -> info .user .attributes , ZEND_STRL ("phpattribute" ))) ) {
6679
+ zend_string_release (lcname );
6683
6680
zend_throw_error (NULL , "Attempting to use class '%s' as attribute that does not have <<PhpAttribute>>." , ZSTR_VAL (attr -> name ));
6684
6681
RETURN_THROWS ();
6685
- } else if (ce -> type == ZEND_INTERNAL_CLASS && zend_hash_exists (& zend_attributes_internal_validators , lower_name ) == 0 ) {
6686
- zend_string_release (lower_name );
6682
+ } else if (ce -> type == ZEND_INTERNAL_CLASS && zend_hash_exists (& zend_attributes_internal_validators , lcname ) == 0 ) {
6683
+ zend_string_release (lcname );
6687
6684
zend_throw_error (NULL , "Attempting to use internal class '%s' as attribute that does not have <<PhpCompilerAttribute>>." , ZSTR_VAL (attr -> name ));
6688
6685
RETURN_THROWS ();
6689
6686
}
6690
6687
6691
- zend_string_release (lower_name );
6688
+ zend_string_release (lcname );
6689
+
6690
+ if (SUCCESS != object_init_ex (& obj , ce )) {
6691
+ RETURN_THROWS ();
6692
+ }
6692
6693
6693
6694
count = zend_hash_num_elements (Z_ARRVAL (attr -> arguments ));
6694
6695
0 commit comments