Project

General

Profile

Bug #13085 » 0001-v2-io.c-io_fwrite-copy-to-hidden-buffer-when-writing.patch

normalperson (Eric Wong), 01/05/2017 11:09 PM

View differences:

io.c
io_fwrite(VALUE str, rb_io_t *fptr, int nosync)
{
int converted = 0;
VALUE tmp = str;
const char *ptr;
long len;
#ifdef _WIN32
if (fptr->mode & FMODE_TTY) {
long len = rb_w32_write_console(str, fptr->fd);
if (len > 0) return len;
}
#endif
str = do_writeconv(str, fptr, &converted);
if (converted)
OBJ_FREEZE(str);
else
str = rb_str_new_frozen(str);
tmp = do_writeconv(str, fptr, &converted);
if (converted) {
rb_obj_hide(tmp);
}
else if (!OBJ_FROZEN_RAW(str)) {
tmp = rb_str_tmp_new(0);
rb_str_buf_append(tmp, str);
}
RSTRING_GETMEM(tmp, ptr, len);
len = io_binwrite(tmp, ptr, len, fptr, nosync);
return io_binwrite(str, RSTRING_PTR(str), RSTRING_LEN(str),
fptr, nosync);
if (tmp != str) {
rb_str_resize(tmp, 0);
rb_gc_force_recycle(tmp);
}
return len;
}
ssize_t
-
(2-2/4)