From 2968e8a2440cf5ef1bafb4abefbab7c1be2513be Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 31 Jul 2024 08:20:07 +0200 Subject: Update to 8.4.0alpha3 fix build with libedit reverting a readline fix --- upstream.patch | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 upstream.patch (limited to 'upstream.patch') 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 +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")) { -- cgit