mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
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
This commit is contained in:
4
NEWS
4
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)
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
Reference in New Issue
Block a user