mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix memory leak in phpdbg calling registered function Partially fix GH-17387
This commit is contained in:
@@ -160,8 +160,9 @@ INPUT ("\\"[#"']|["]("\\\\"|"\\"["]|[^\n\000"])*["]|[']("\\"[']|"\\\\"|[^\
|
||||
|
||||
<NORMAL>{GENERIC_ID} {
|
||||
phpdbg_init_param(yylval, STR_PARAM);
|
||||
yylval->str = estrndup(yytext, yyleng - unescape_string(yytext));
|
||||
yylval->len = yyleng;
|
||||
size_t len = yyleng - unescape_string(yytext);
|
||||
yylval->str = estrndup(yytext, len);
|
||||
yylval->len = len;
|
||||
return T_ID;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +168,10 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */
|
||||
zend_call_known_function(user_fn, NULL, NULL, NULL, 0, NULL, params_ht);
|
||||
phpdbg_out("\n");
|
||||
|
||||
if (params_ht) {
|
||||
zend_array_destroy(params_ht);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
24
sapi/phpdbg/tests/register_function_leak.phpt
Normal file
24
sapi/phpdbg/tests/register_function_leak.phpt
Normal file
@@ -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>
|
||||
Reference in New Issue
Block a user