We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4335e31 commit f472621Copy full SHA for f472621
ext/readline/readline.c
@@ -190,10 +190,16 @@ PHP_FUNCTION(readline_info)
190
if (strlen(oldstr) < Z_STRLEN_P(value)) {
191
rl_extend_line_buffer(Z_STRLEN_P(value) + 1);
192
}
193
- strcpy(rl_line_buffer, Z_STRVAL_P(value));
+ memcpy(rl_line_buffer, Z_STRVAL_P(value), Z_STRLEN_P(value) + 1);
194
rl_end = Z_STRLEN_P(value);
195
#else
196
- rl_line_buffer = strdup(Z_STRVAL_P(value));
+ char *tmp = strdup(Z_STRVAL_P(value));
197
+ if (tmp) {
198
+ if (rl_line_buffer) {
199
+ free(rl_line_buffer);
200
+ }
201
+ rl_line_buffer = tmp;
202
203
#endif
204
205
RETVAL_STRING(SAFE_STRING(oldstr));
0 commit comments