From b84e28d13338c301c2264d9240ad467ad4f4216f Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 27 Feb 2015 03:54:54 +0000 Subject: io.c: discard buffer always * io.c (copy_stream_fallback_body): discard buffer always before exit or exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io.c b/io.c index 4610e8514a..015ff6cd5c 100644 --- a/io.c +++ b/io.c @@ -10462,11 +10462,11 @@ copy_stream_fallback_body(VALUE arg) ssize_t ss; rb_str_resize(buf, buflen); ss = maygvl_copy_stream_read(1, stp, RSTRING_PTR(buf), l, off); + rb_str_resize(buf, ss > 0 ? ss : 0); if (ss == -1) return Qnil; if (ss == 0) rb_eof_error(); - rb_str_resize(buf, ss); if (off != (off_t)-1) off += ss; } -- cgit v1.2.3