summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'time.c')
-rw-r--r--time.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/time.c b/time.c
index 223f5de8ae..0d7216acaa 100644
--- a/time.c
+++ b/time.c
@@ -793,12 +793,23 @@ time_hash(time)
return LONG2FIX(hash);
}
+static void
+time_modify(time)
+ VALUE time;
+{
+ rb_check_frozen(time);
+ if (!OBJ_TAINTED(time) && rb_safe_level() >= 4)
+ rb_raise(rb_eSecurityError, "Insecure: can't modify Time");
+}
+
static VALUE
time_become(copy, time)
VALUE copy, time;
{
struct time_object *tobj, *tcopy;
+ if (copy == time) return copy;
+ time_modify(copy);
if (TYPE(time) != T_DATA || RDATA(time)->dfree != time_free) {
rb_raise(rb_eTypeError, "wrong argument type");
}
@@ -818,15 +829,6 @@ time_dup(time)
return dup;
}
-static void
-time_modify(time)
- VALUE time;
-{
- if (OBJ_FROZEN(time)) rb_error_frozen("Time");
- if (!OBJ_TAINTED(time) && rb_safe_level() >= 4)
- rb_raise(rb_eSecurityError, "Insecure: can't modify Time");
-}
-
static VALUE
time_localtime(time)
VALUE time;