Skip to content

Commit c2b23d8

Browse files
committed
Fix leak in isDefaultValueAvailable()
Exposed in Symfony due to exit changes.
1 parent 8c11d8f commit c2b23d8

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

ext/reflection/php_reflection.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2813,10 +2813,11 @@ ZEND_METHOD(ReflectionParameter, isDefaultValueConstant)
28132813
if (Z_TYPE(default_value) == IS_CONSTANT_AST) {
28142814
zend_ast *ast = Z_ASTVAL(default_value);
28152815
RETVAL_BOOL(ast->kind == ZEND_AST_CONSTANT || ast->kind == ZEND_AST_CONSTANT_CLASS);
2816-
zval_ptr_dtor_nogc(&default_value);
28172816
} else {
2818-
RETURN_FALSE;
2817+
RETVAL_FALSE;
28192818
}
2819+
2820+
zval_ptr_dtor_nogc(&default_value);
28202821
}
28212822
/* }}} */
28222823

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Check that isDefaultValueConstant() does not leak
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
public function method($param = [123]) {}
8+
}
9+
10+
$rp = new ReflectionParameter(['Test', 'method'], 'param');
11+
var_dump($rp->isDefaultValueAvailable());
12+
var_dump($rp->isDefaultValueConstant());
13+
var_dump($rp->getDefaultValue());
14+
15+
?>
16+
--EXPECT--
17+
bool(true)
18+
bool(false)
19+
array(1) {
20+
[0]=>
21+
int(123)
22+
}

0 commit comments

Comments
 (0)