Commit 43838c4ca2a for php.net
commit 43838c4ca2aa97e2a1f4dd2eccedcec432df35a2
Author: Ilia Alshanetsky <ilia@ilia.ws>
Date: Sun Jun 7 16:40:20 2026 -0400
readline: Fix memory leak in interactive shell INI directive
The readline() buffer is not freed on the #name=value INI-directive
branch before continue, unlike the sibling branches.
Closes GH-22255
diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c
index 2b0950784bf..ca4e8eb4fe9 100644
--- a/ext/readline/readline_cli.c
+++ b/ext/readline/readline_cli.c
@@ -662,6 +662,7 @@ static int readline_shell_run(void) /* {{{ */
zend_string_release_ex(prompt, 0);
/* TODO: This might be wrong! */
prompt = cli_get_prompt("php", '>');
+ free(line);
continue;
}
}
diff --git a/ext/readline/tests/readline_cli_ini_directive.phpt b/ext/readline/tests/readline_cli_ini_directive.phpt
new file mode 100644
index 00000000000..ebf4ac10a28
--- /dev/null
+++ b/ext/readline/tests/readline_cli_ini_directive.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Interactive shell: setting an INI directive via #name=value
+--EXTENSIONS--
+readline
+--SKIPIF--
+<?php
+if (!function_exists('proc_open')) die('skip proc_open() not available');
+?>
+--FILE--
+<?php
+$php = getenv('TEST_PHP_EXECUTABLE');
+$ini = getenv('TEST_PHP_EXTRA_ARGS');
+$descriptorspec = [['pipe', 'r'], STDOUT, STDERR];
+$proc = proc_open("$php $ini -a", $descriptorspec, $pipes);
+fwrite($pipes[0], "#precision=5\n");
+fwrite($pipes[0], "echo 'INI[' . ini_get('precision') . ']';\n");
+fclose($pipes[0]);
+proc_close($proc);
+?>
+--EXPECTF--
+%AINI[5]%A