summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/object.c b/object.c
index 319abd3..9c5163a 100644
--- a/object.c
+++ b/object.c
@@ -465,8 +465,12 @@ rb_mod_clone(module)
clone->super = RCLASS(module)->super;
clone->iv_tbl = 0;
clone->m_tbl = 0; /* avoid GC crashing */
- clone->iv_tbl = st_copy(RCLASS(module)->iv_tbl);
- clone->m_tbl = st_copy(RCLASS(module)->m_tbl);
+ if (RCLASS(module)->iv_tbl) {
+ clone->iv_tbl = st_copy(RCLASS(module)->iv_tbl);
+ }
+ if (RCLASS(module)->m_tbl) {
+ clone->m_tbl = st_copy(RCLASS(module)->m_tbl);
+ }
return (VALUE)clone;
}