Skip to content

Commit

Permalink
Fix memory leak in phpdbg calling registered function
Browse files Browse the repository at this point in the history
Closes phpGH-17635.
  • Loading branch information
nielsdos committed Jan 30, 2025
1 parent 5447473 commit 62bbfde
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PHP NEWS

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

13 Feb 2025, PHP 8.3.17

Expand Down
3 changes: 3 additions & 0 deletions sapi/phpdbg/phpdbg_prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */

zval_ptr_dtor_str(&fci.function_name);
efree(lc_name);
if (fci.named_params) {
zend_array_destroy(fci.named_params);
}

return SUCCESS;
}
Expand Down
24 changes: 24 additions & 0 deletions sapi/phpdbg/tests/register_function_leak.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
registering a function and calling it leaks arguments memory
--FILE--
<?php
echo "Done\n";
?>
--PHPDBG--
register var_dump
var_dump "a" "b"
register flush
flush
r
q
--EXPECTF--
[Successful compilation of %s]
prompt> [Registered var_dump]
prompt> string(1) "a"
string(1) "b"

prompt> [Registered flush]
prompt>
prompt> Done
[Script ended normally]
prompt>

0 comments on commit 62bbfde

Please sign in to comment.