diff options
Diffstat (limited to 'upstream.patch')
-rw-r--r-- | upstream.patch | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/upstream.patch b/upstream.patch new file mode 100644 index 0000000..a08b628 --- /dev/null +++ b/upstream.patch @@ -0,0 +1,61 @@ +From a7d856d9bf784a93aa690e763b082d92629cfd83 Mon Sep 17 00:00:00 2001 +From: David Carlier <devnexen@gmail.com> +Date: Sat, 27 Jul 2024 09:30:11 +0100 +Subject: [PATCH] ext/readline: fix global readline vars when updating + rl_line_buffer. + +if the new value was larger, rl_line_buffer_length was never updated. +neither was rl_end (on unixes). + +close GH-15120 +--- + NEWS | 4 ++++ + ext/readline/readline.c | 17 +++++++++++++++-- + 2 files changed, 19 insertions(+), 2 deletions(-) + +diff --git a/NEWS b/NEWS +index 147d6ce70f504..f945ee519932f 100644 +--- a/NEWS ++++ b/NEWS +@@ -50,6 +50,10 @@ PHP NEWS + . Fixed bug GH-15094 (php_random_default_engine() is not C++ conforming). + (cmb) + ++- Readline: ++ . Fixed readline_info, rl_line_buffer_length/rl_len globals on update. ++ (David Carlier) ++ + - Standard: + . Fix references in request_parse_body() options array. (nielsdos) + . Add RoundingMode enum. (timwolla, saki) +diff --git a/ext/readline/readline.c b/ext/readline/readline.c +index fc36114745752..eca64f45b1586 100644 +--- a/ext/readline/readline.c ++++ b/ext/readline/readline.c +@@ -183,11 +183,24 @@ PHP_FUNCTION(readline_info) + if (zend_string_equals_literal_ci(what,"line_buffer")) { + oldstr = rl_line_buffer; + if (value) { +- /* XXX if (rl_line_buffer) free(rl_line_buffer); */ + if (!try_convert_to_string(value)) { + RETURN_THROWS(); + } +- rl_line_buffer = strdup(Z_STRVAL_P(value)); ++#ifndef PHP_WIN32 ++ if (strlen(oldstr) < Z_STRLEN_P(value)) { ++ rl_extend_line_buffer(Z_STRLEN_P(value) + 1); ++ } ++ memcpy(rl_line_buffer, Z_STRVAL_P(value), Z_STRLEN_P(value) + 1); ++ rl_end = Z_STRLEN_P(value); ++#else ++ char *tmp = strdup(Z_STRVAL_P(value)); ++ if (tmp) { ++ if (rl_line_buffer) { ++ free(rl_line_buffer); ++ } ++ rl_line_buffer = tmp; ++ } ++#endif + } + RETVAL_STRING(SAFE_STRING(oldstr)); + } else if (zend_string_equals_literal_ci(what, "point")) { |