Skip to content

Commit 717bf13

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

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

ext/reflection/php_reflection.c

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

0 commit comments

Comments
 (0)