Skip to content

Commit 513224c

Browse files
ju1iuskocsismate
authored andcommitted
prevents using resource as a zend_type
Closes #13102
1 parent a96cc80 commit 513224c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/zend_API.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,6 +2772,9 @@ ZEND_END_ARG_INFO()
27722772

27732773
static zend_always_inline void zend_normalize_internal_type(zend_type *type) {
27742774
ZEND_ASSERT(!ZEND_TYPE_HAS_LITERAL_NAME(*type));
2775+
if (ZEND_TYPE_PURE_MASK(*type) != MAY_BE_ANY) {
2776+
ZEND_ASSERT(!ZEND_TYPE_CONTAINS_CODE(*type, IS_RESOURCE) && "resource is not allowed in a zend_type");
2777+
}
27752778
zend_type *current;
27762779
ZEND_TYPE_FOREACH(*type, current) {
27772780
if (ZEND_TYPE_HAS_NAME(*current)) {
@@ -4642,6 +4645,9 @@ ZEND_API zend_class_constant *zend_declare_typed_class_constant(zend_class_entry
46424645

46434646
if (ce->type == ZEND_INTERNAL_CLASS) {
46444647
c = pemalloc(sizeof(zend_class_constant), 1);
4648+
if (ZEND_TYPE_PURE_MASK(type) != MAY_BE_ANY) {
4649+
ZEND_ASSERT(!ZEND_TYPE_CONTAINS_CODE(type, IS_RESOURCE) && "resource is not allowed in a zend_type");
4650+
}
46454651
} else {
46464652
c = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
46474653
}

0 commit comments

Comments
 (0)