Skip to content

Commit 62bbfde

Browse files
committed
Fix memory leak in phpdbg calling registered function
Closes GH-17635.
1 parent 5447473 commit 62bbfde

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PHP NEWS
1111

1212
- PHPDBG:
1313
. Partially fixed bug GH-17387 (Trivial crash in phpdbg lexer). (nielsdos)
14+
. Fix memory leak in phpdbg calling registered function. (nielsdos)
1415

1516
13 Feb 2025, PHP 8.3.17
1617

sapi/phpdbg/phpdbg_prompt.c

+3
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */
189189

190190
zval_ptr_dtor_str(&fci.function_name);
191191
efree(lc_name);
192+
if (fci.named_params) {
193+
zend_array_destroy(fci.named_params);
194+
}
192195

193196
return SUCCESS;
194197
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
registering a function and calling it leaks arguments memory
3+
--FILE--
4+
<?php
5+
echo "Done\n";
6+
?>
7+
--PHPDBG--
8+
register var_dump
9+
var_dump "a" "b"
10+
register flush
11+
flush
12+
r
13+
q
14+
--EXPECTF--
15+
[Successful compilation of %s]
16+
prompt> [Registered var_dump]
17+
prompt> string(1) "a"
18+
string(1) "b"
19+
20+
prompt> [Registered flush]
21+
prompt>
22+
prompt> Done
23+
[Script ended normally]
24+
prompt>

0 commit comments

Comments
 (0)