diff options
author | kazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-16 16:49:44 +0000 |
---|---|---|
committer | kazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-16 16:49:44 +0000 |
commit | ea6511c63ae463ec63c51f344ee0a2fe83e8c9d0 (patch) | |
tree | c158c7dea587c9db1c2074d0351e82936236eb8a /string.c | |
parent | 2cab78a9ff5f14b657bed44bb71c124a33b107af (diff) | |
download | ruby-ea6511c63ae463ec63c51f344ee0a2fe83e8c9d0.tar.gz |
* string.c (trnext): fix bug with string ending with '\\'.
[ruby-dev:45374][Bug #6160]
* test/ruby/test_string.rb (TestString#test_delete): test for
above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -4956,12 +4956,12 @@ trnext(struct tr *t, rb_encoding *enc) for (;;) { if (!t->gen) { if (t->p == t->pend) return -1; - if (rb_enc_ascget(t->p, t->pend, &n, enc) == '\\') { + if (rb_enc_ascget(t->p, t->pend, &n, enc) == '\\' && t->p + n < t->pend) { t->p += n; } t->now = rb_enc_codepoint_len(t->p, t->pend, &n, enc); t->p += n; - if (rb_enc_ascget(t->p, t->pend, &n, enc) == '-') { + if (rb_enc_ascget(t->p, t->pend, &n, enc) == '-' && t->p + n < t->pend) { t->p += n; if (t->p < t->pend) { unsigned int c = rb_enc_codepoint_len(t->p, t->pend, &n, enc); |