diff --git a/NEWS b/NEWS index a8d6d6ee6fe..fc7e534d604 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,10 @@ PHP NEWS - Phar: . Add missing filter cleanups on phar failure. (nielsdos) +- Readline: + . Fix memory leak when calloc() fails in php_readline_completion_cb(). + (nielsdos) + 05 Jun 2025, PHP 8.3.22 - Core: diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 1bd5e2fd605..4da9f359515 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -458,13 +458,14 @@ char **php_readline_completion_cb(const char *text, int start, int end) /* libedit will read matches[2] */ matches = calloc(3, sizeof(char *)); if (!matches) { - return NULL; + goto out; } matches[0] = strdup(""); } } } +out: zval_ptr_dtor(¶ms[0]); zval_ptr_dtor(&_readline_array);