diff --git a/ChangeLog b/ChangeLog index 675f55409b..a31a883e15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Oct 30 18:54:04 2009 Yukihiro Matsumoto + + * string.c (trnext): detect empty range and raise exception. + [ruby-dev:39108] + Fri Oct 30 17:01:46 2009 Nobuyoshi Nakada * vm_eval.c (enum call_type): get rid of last comma. diff --git a/string.c b/string.c index 1dfab48cc1..e7f7e8673a 100644 --- a/string.c +++ b/string.c @@ -4642,7 +4642,17 @@ trnext(struct tr *t, rb_encoding *enc) if (t->p < t->pend) { unsigned int c = rb_enc_codepoint_len(t->p, t->pend, &n, enc); t->p += n; - if (t->now > c) continue; + if (t->now > c) { + if (t->now < 0x80 && c < 0x80) { + rb_raise(rb_eArgError, + "invalid range \"%c-%c\" in string transliteration", + t->now, c); + } + else { + rb_raise(rb_eArgError, "invalid range in string transliteration"); + } + continue; /* not reached */ + } t->gen = 1; t->max = c; }