summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-14 02:08:31 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-14 02:08:31 +0000
commit632ab19c4ddfdd7bf73adf0215e488382f02bb1a (patch)
tree355befc7d01be04f650a952105136a41dc6021f2 /class.c
parentbd255c46866f4599ab787d4748f768bbfa5842b0 (diff)
class.c: cyclic prepend
* class.c (include_modules_at): detect cyclic prepend with original method table. [ruby-core:52205] [Bug #7841] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/class.c b/class.c
index 36e7b76..c1903f9 100644
--- a/class.c
+++ b/class.c
@@ -681,7 +681,7 @@ rb_include_class_new(VALUE module, VALUE super)
return (VALUE)klass;
}
-static int include_modules_at(VALUE klass, VALUE c, VALUE module);
+static int include_modules_at(const VALUE klass, VALUE c, VALUE module);
void
rb_include_module(VALUE klass, VALUE module)
@@ -713,17 +713,18 @@ add_refined_method_entry_i(st_data_t key, st_data_t value, st_data_t data)
}
static int
-include_modules_at(VALUE klass, VALUE c, VALUE module)
+include_modules_at(const VALUE klass, VALUE c, VALUE module)
{
VALUE p;
int changed = 0;
+ const st_table *const klass_m_tbl = RCLASS_M_TBL(RCLASS_ORIGIN(klass));
while (module) {
int superclass_seen = FALSE;
if (RCLASS_ORIGIN(module) != module)
goto skip;
- if (RCLASS_M_TBL(klass) && RCLASS_M_TBL(klass) == RCLASS_M_TBL(module))
+ if (klass_m_tbl && klass_m_tbl == RCLASS_M_TBL(module))
return -1;
/* ignore if the module included already in superclasses */
for (p = RCLASS_SUPER(klass); p; p = RCLASS_SUPER(p)) {