Skip to content

Commit f472621

Browse files
committed
mem leak for windows ?
1 parent 4335e31 commit f472621

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: ext/readline/readline.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,16 @@ PHP_FUNCTION(readline_info)
190190
if (strlen(oldstr) < Z_STRLEN_P(value)) {
191191
rl_extend_line_buffer(Z_STRLEN_P(value) + 1);
192192
}
193-
strcpy(rl_line_buffer, Z_STRVAL_P(value));
193+
memcpy(rl_line_buffer, Z_STRVAL_P(value), Z_STRLEN_P(value) + 1);
194194
rl_end = Z_STRLEN_P(value);
195195
#else
196-
rl_line_buffer = strdup(Z_STRVAL_P(value));
196+
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+
}
197203
#endif
198204
}
199205
RETVAL_STRING(SAFE_STRING(oldstr));

0 commit comments

Comments
 (0)