From f36ec11194896b8d9e206f6f06df545b17430da8 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 24 May 2025 16:17:43 +0200 Subject: [PATCH] Fix memory leak when calloc() fails in php_readline_completion_cb() --- ext/readline/readline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 1bd5e2fd6059a..4da9f35951527 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);