From 2073258a7d192e8d2bc853e10464a7a5fcac8f2d Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 5 Jun 2012 11:13:18 +0000 Subject: obj_init_copy * object.c (rb_obj_init_copy): should check if trusted too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- re.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 're.c') diff --git a/re.c b/re.c index 500173d3cb..4191d5bcb8 100644 --- a/re.c +++ b/re.c @@ -939,11 +939,8 @@ match_init_copy(VALUE obj, VALUE orig) { struct rmatch *rm; - if (obj == orig) return obj; + if (!OBJ_INIT_COPY(obj, orig)) return obj; - if (!rb_obj_is_instance_of(orig, rb_obj_class(obj))) { - rb_raise(rb_eTypeError, "wrong argument class"); - } RMATCH(obj)->str = RMATCH(orig)->str; RMATCH(obj)->regexp = RMATCH(orig)->regexp; @@ -3260,12 +3257,7 @@ rb_reg_init_copy(VALUE copy, VALUE re) const char *s; long len; - if (copy == re) return copy; - rb_check_frozen(copy); - /* need better argument type check */ - if (!rb_obj_is_instance_of(re, rb_obj_class(copy))) { - rb_raise(rb_eTypeError, "wrong argument type"); - } + if (!OBJ_INIT_COPY(copy, re)) return copy; rb_reg_check(re); s = RREGEXP_SRC_PTR(re); len = RREGEXP_SRC_LEN(re); -- cgit v1.2.3