Skip to content

Commit eb85f5a

Browse files
committed
Address review comments
1 parent 618f5d0 commit eb85f5a

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

Zend/zend_attributes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static void attribute_ptr_dtor(zval *v) /* {{{ */
9393
ZEND_API void zend_compiler_attribute_register(zend_class_entry *ce, zend_attributes_internal_validator validator)
9494
{
9595
if (ce->type != ZEND_INTERNAL_CLASS) {
96-
return;
96+
zend_error_noreturn(E_ERROR, "Only internal classes can be registered as compiler attribute");
9797
}
9898

9999
zend_string *lcname = zend_string_tolower_ex(ce->name, 1);
@@ -107,10 +107,10 @@ ZEND_API void zend_compiler_attribute_register(zend_class_entry *ce, zend_attrib
107107
zend_hash_init(ce->attributes, 8, NULL, attribute_ptr_dtor, 1);
108108
}
109109

110-
zend_attribute *attr = emalloc(ZEND_ATTRIBUTE_SIZE(0));
110+
zend_attribute *attr = pemalloc(ZEND_ATTRIBUTE_SIZE(0), 1);
111111

112112
attr->name = zend_string_copy(zend_ce_php_attribute->name);
113-
attr->lcname = zend_string_tolower(attr->name);
113+
attr->lcname = zend_string_tolower_ex(attr->name, 1);
114114
attr->offset = 0;
115115
attr->argc = 0;
116116

ext/reflection/php_reflection.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,8 @@ static void reflection_attribute_factory(zval *object, zend_attribute *data, zen
10921092
static int read_attributes(zval *ret, HashTable *attributes, zend_class_entry *scope,
10931093
uint32_t offset, zend_string *name, zend_class_entry *base) /* {{{ */
10941094
{
1095+
ZEND_ASSERT(attributes != NULL);
1096+
10951097
zend_attribute *attr;
10961098
zval tmp;
10971099

@@ -1110,10 +1112,6 @@ static int read_attributes(zval *ret, HashTable *attributes, zend_class_entry *s
11101112
return SUCCESS;
11111113
}
11121114

1113-
if (!attributes) {
1114-
return SUCCESS;
1115-
}
1116-
11171115
ZEND_HASH_FOREACH_PTR(attributes, attr) {
11181116
if (attr->offset != offset) {
11191117
continue;
@@ -4180,15 +4178,9 @@ ZEND_METHOD(ReflectionClass, getAttributes)
41804178
reflection_object *intern;
41814179
zend_class_entry *ce;
41824180

4183-
HashTable *attributes = NULL;
4184-
zend_class_entry *scope = NULL;
4185-
41864181
GET_REFLECTION_OBJECT_PTR(ce);
41874182

4188-
attributes = ce->attributes;
4189-
scope = ce;
4190-
4191-
reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU, attributes, 0, scope);
4183+
reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU, ce->attributes, 0, ce);
41924184
}
41934185
/* }}} */
41944186

0 commit comments

Comments
 (0)