From ab5b3e61d787fe8458fb330a86ddb7f6fa44774f Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 3 Jul 2023 18:57:20 +0200 Subject: [PATCH 1/3] Fix type macros for C++ They are now used in arginfo files. --- Zend/zend_types.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Zend/zend_types.h b/Zend/zend_types.h index af5f3821723f..58d13c888c8f 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -263,28 +263,36 @@ typedef struct { #define ZEND_TYPE_ALLOW_NULL(t) \ (((t).type_mask & _ZEND_TYPE_NULLABLE_BIT) != 0) +#ifdef __cplusplus +# define _ZEND_TYPE_PREFIX zend_type +#else +/* FIXME: We could add (zend_type) here at some point but this breaks in MSVC because + * (zend_type)(zend_type){} is no longer considered constant. */ +# define _ZEND_TYPE_PREFIX +#endif + #define ZEND_TYPE_INIT_NONE(extra_flags) \ - { NULL, (extra_flags) } + _ZEND_TYPE_PREFIX { NULL, (extra_flags) } #define ZEND_TYPE_INIT_MASK(_type_mask) \ - { NULL, (_type_mask) } + _ZEND_TYPE_PREFIX { NULL, (_type_mask) } #define ZEND_TYPE_INIT_CODE(code, allow_null, extra_flags) \ ZEND_TYPE_INIT_MASK(((code) == _IS_BOOL ? MAY_BE_BOOL : ( (code) == IS_ITERABLE ? _ZEND_TYPE_ITERABLE_BIT : ((code) == IS_MIXED ? MAY_BE_ANY : (1 << (code))))) \ | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) | (extra_flags)) #define ZEND_TYPE_INIT_PTR(ptr, type_kind, allow_null, extra_flags) \ - { (void *) (ptr), \ + _ZEND_TYPE_PREFIX { (void *) (ptr), \ (type_kind) | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) | (extra_flags) } #define ZEND_TYPE_INIT_PTR_MASK(ptr, type_mask) \ - { (void *) (ptr), (type_mask) } + _ZEND_TYPE_PREFIX { (void *) (ptr), (type_mask) } #define ZEND_TYPE_INIT_UNION(ptr, extra_flags) \ - { (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_UNION_BIT) | (extra_flags) } + _ZEND_TYPE_PREFIX { (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_UNION_BIT) | (extra_flags) } #define ZEND_TYPE_INIT_INTERSECTION(ptr, extra_flags) \ - { (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_INTERSECTION_BIT) | (extra_flags) } + _ZEND_TYPE_PREFIX { (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_INTERSECTION_BIT) | (extra_flags) } #define ZEND_TYPE_INIT_CLASS(class_name, allow_null, extra_flags) \ ZEND_TYPE_INIT_PTR(class_name, _ZEND_TYPE_NAME_BIT, allow_null, extra_flags) From 91425d3938aaf5dee26ad796f9a26bbce94aff9b Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 3 Jul 2023 22:15:27 +0200 Subject: [PATCH 2/3] Fix leaking prop_info.attributes of internal classes --- Zend/zend_opcode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index dc968bc39530..0ec140c7e35e 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -455,6 +455,9 @@ ZEND_API void destroy_zend_class(zval *zv) if (prop_info->ce == ce) { zend_string_release(prop_info->name); zend_type_release(prop_info->type, /* persistent */ 1); + if (prop_info->attributes) { + zend_hash_release(prop_info->attributes); + } free(prop_info); } } ZEND_HASH_FOREACH_END(); From d2aee3c43f9c1df6d548a9f2a06fcb35c8504a76 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 3 Jul 2023 22:31:53 +0200 Subject: [PATCH 3/3] Testing