diff --git a/ChangeLog b/ChangeLog index 1385d18fff..1f97e38b50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 10 11:25:53 2008 NARUSE, Yui + + * re.c (rb_reg_initialize): raise RegexpError when encoding + is dummy encoding. [ruby-dev:37091] + Wed Dec 10 01:28:16 2008 NAKAMURA Usaku * common.mk (win32.obj): depend on headers. diff --git a/re.c b/re.c index 3a2aa5d362..a45ae47d9f 100644 --- a/re.c +++ b/re.c @@ -2312,6 +2312,11 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc, rb_raise(rb_eTypeError, "already initialized regexp"); re->ptr = 0; + if (rb_enc_dummy_p(enc)) { + strcpy(err, "can't make regexp with dummy encoding"); + return -1; + } + unescaped = rb_reg_preprocess(s, s+len, enc, &fixed_enc, err); if (unescaped == Qnil) return -1;