Skip to content

Commit fd6d2cc

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix memory leak
2 parents e00dadf + 482ae71 commit fd6d2cc

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Union and intersection type leaks
3+
--FILE--
4+
<?php
5+
eval('abstract class y {function y(): (y&yy)|t {}}');
6+
?>
7+
DONE
8+
--EXPECTF--
9+
DONE

Zend/zend_opcode.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,15 @@ ZEND_API void destroy_zend_function(zend_function *function)
110110

111111
ZEND_API void zend_type_release(zend_type type, bool persistent) {
112112
if (ZEND_TYPE_HAS_LIST(type)) {
113-
zend_type *list_type;
113+
zend_type *list_type, *sublist_type;
114114
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(type), list_type) {
115-
if (ZEND_TYPE_HAS_NAME(*list_type)) {
115+
if (ZEND_TYPE_HAS_LIST(*list_type)) {
116+
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(*list_type), sublist_type) {
117+
if (ZEND_TYPE_HAS_NAME(*sublist_type)) {
118+
zend_string_release(ZEND_TYPE_NAME(*sublist_type));
119+
}
120+
} ZEND_TYPE_LIST_FOREACH_END();
121+
} else if (ZEND_TYPE_HAS_NAME(*list_type)) {
116122
zend_string_release(ZEND_TYPE_NAME(*list_type));
117123
}
118124
} ZEND_TYPE_LIST_FOREACH_END();

0 commit comments

Comments
 (0)