From d433a70b5dca5c501e53d89e155f7bbba17fdbc7 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 10 Dec 2008 02:29:05 +0000 Subject: [PATCH] * re.c (rb_reg_initialize): raise RegexpError when encoding is dummy encoding. [ruby-dev:37091] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ re.c | 5 +++++ 2 files changed, 10 insertions(+) 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;