Skip to content

Commit d44ce02

Browse files
committed
Fix double construct leak
1 parent 4a4b03b commit d44ce02

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

ext/reflection/php_reflection.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7242,7 +7242,9 @@ ZEND_METHOD(ReflectionConstant, __construct)
72427242
intern->ptr = const_;
72437243
intern->ref_type = REF_TYPE_OTHER;
72447244

7245-
ZVAL_STR_COPY(reflection_prop_name(object), name);
7245+
zval *name_zv = reflection_prop_name(object);
7246+
zval_ptr_dtor(name_zv);
7247+
ZVAL_STR_COPY(name_zv, name);
72467248
}
72477249

72487250
ZEND_METHOD(ReflectionConstant, getName)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
ReflectionConstant double construct call
3+
--FILE--
4+
<?php
5+
6+
const C1 = 42;
7+
const C2 = 43;
8+
9+
$r = new ReflectionConstant('C' . mt_rand(1, 1));
10+
var_dump($r);
11+
12+
$r->__construct('C' . mt_rand(2, 2));
13+
var_dump($r);
14+
15+
?>
16+
--EXPECT--
17+
object(ReflectionConstant)#1 (1) {
18+
["name"]=>
19+
string(2) "C1"
20+
}
21+
object(ReflectionConstant)#1 (1) {
22+
["name"]=>
23+
string(2) "C2"
24+
}

0 commit comments

Comments
 (0)