From 84bf320bea3bce391ecc19e6004c232ff76d5c43 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 17 Aug 2015 02:57:39 +0000 Subject: io.c: raise at incomplete char * io.c (rb_io_each_codepoint): raise an exception at incomplete character before EOF when conversion takes place. [Bug #11444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index fc973bc5c8..93a808b140 100644 --- a/io.c +++ b/io.c @@ -3727,13 +3727,16 @@ rb_io_each_codepoint(VALUE io) } if (more_char(fptr) == MORE_CHAR_FINISHED) { clear_readconv(fptr); - /* ignore an incomplete character before EOF */ + if (!MBCLEN_CHARFOUND_P(r)) { + enc = fptr->encs.enc; + goto invalid; + } return io; } } if (MBCLEN_INVALID_P(r)) { - rb_raise(rb_eArgError, "invalid byte sequence in %s", - rb_enc_name(fptr->encs.enc)); + enc = fptr->encs.enc; + goto invalid; } n = MBCLEN_CHARFOUND_LEN(r); if (fptr->encs.enc) { -- cgit v1.2.3