Skip to content

Commit 6832851

Browse files
committed
Fix memory leak
Fixes oss-fuzz #54320
1 parent 351055e commit 6832851

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Zend/tests/class_constants_007.phpt

Lines changed: 13 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ static void do_inherit_class_constant(zend_string *name, zend_class_constant *pa
13541354
c = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
13551355
memcpy(c, parent_const, sizeof(zend_class_constant));
13561356
parent_const = c;
1357+
Z_CONSTANT_FLAGS(c->value) |= CONST_OWNED;
13571358
}
13581359
}
13591360
if (ce->type & ZEND_INTERNAL_CLASS) {

0 commit comments

Comments
 (0)