We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a7f0fe1 commit e3cde84Copy full SHA for e3cde84
ext/readline/readline.c
@@ -183,11 +183,16 @@ PHP_FUNCTION(readline_info)
183
if (zend_string_equals_literal_ci(what,"line_buffer")) {
184
oldstr = rl_line_buffer;
185
if (value) {
186
- /* XXX if (rl_line_buffer) free(rl_line_buffer); */
187
if (!try_convert_to_string(value)) {
188
RETURN_THROWS();
189
}
190
- rl_line_buffer = strdup(Z_STRVAL_P(value));
+ if (strlen(oldstr) < Z_STRLEN_P(value)) {
+ rl_extend_line_buffer(Z_STRLEN_P(value) + 1);
191
+ }
192
+ strcpy(rl_line_buffer, Z_STRVAL_P(value));
193
+#ifndef PHP_WIN32
194
+ rl_end = Z_STRLEN_P(value);
195
+#endif
196
197
RETVAL_STRING(SAFE_STRING(oldstr));
198
} else if (zend_string_equals_literal_ci(what, "point")) {
0 commit comments