Skip to content

Commit f763cfd

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix memory leak
2 parents 83a352a + 6832851 commit f763cfd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Zend/tests/class_constants_007.phpt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Ownership of constant expression inhereted from immutable class should be transfered to class
3+
--FILE--
4+
<?php
5+
class A {
6+
const X = ' ' . self::Y;
7+
const Y = ' ';
8+
}
9+
eval('class B extends A{}');
10+
var_dump(B::X);
11+
?>
12+
--EXPECT--
13+
string(2) " "

Zend/zend_inheritance.c

+1
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,7 @@ static void do_inherit_class_constant(zend_string *name, zend_class_constant *pa
13851385
c = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
13861386
memcpy(c, parent_const, sizeof(zend_class_constant));
13871387
parent_const = c;
1388+
Z_CONSTANT_FLAGS(c->value) |= CONST_OWNED;
13881389
}
13891390
}
13901391
if (ce->type & ZEND_INTERNAL_CLASS) {

0 commit comments

Comments
 (0)