summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-24 07:34:07 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-24 07:34:07 +0000
commit4bcfd50ee7d33d23dcccfbbaf197051ebb4e34a6 (patch)
tree23a7d3a752ad0c5401a148d2a83bb765656e7f06 /io.c
parente36dd522913f79973f0493cc885ce066920ed6e2 (diff)
* io.c (rb_io_getline_fast): the end point of left_char_head()
must be the last character. [ruby-cvs:22445] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/io.c b/io.c
index 79f2396383..10b1d9b582 100644
--- a/io.c
+++ b/io.c
@@ -1799,12 +1799,14 @@ rb_io_getline_fast(rb_io_t *fptr)
if (pending > 0) {
const char *p = READ_DATA_PENDING_PTR(fptr);
+ const char *pend = p + pending - 1;
const char *e;
e = memchr(p, '\n', pending);
if (e) {
const char *p0 = rb_enc_left_char_head(p, e, enc);
- const char *pend = rb_enc_left_char_head(p, p+pending, enc);
+
+ pend = rb_enc_left_char_head(p0, pend, enc);
if (rb_enc_is_newline(p0, pend, enc)) {
pending = p0 - p + rb_enc_mbclen(p0, pend, enc);
}