mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
initialize_copy: copy destination object may not be intialized
This commit is contained in:
@@ -496,6 +496,10 @@ mrb_time_initialize_copy(mrb_state *mrb, mrb_value copy)
|
||||
if (!mrb_obj_is_instance_of(mrb, src, mrb_obj_class(mrb, copy))) {
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "wrong argument class");
|
||||
}
|
||||
if (!DATA_PTR(copy)) {
|
||||
DATA_PTR(copy) = mrb_malloc(mrb, sizeof(struct mrb_time));
|
||||
DATA_TYPE(copy) = &mrb_time_type;
|
||||
}
|
||||
memcpy(DATA_PTR(copy), DATA_PTR(src), sizeof(struct mrb_time));
|
||||
return copy;
|
||||
}
|
||||
|
||||
+1
-2
@@ -43,7 +43,6 @@ assert("yday") { t1.yday == 71 }
|
||||
assert("year") { t1.year == 2011 }
|
||||
|
||||
t2 = Time.at(7.0e6)
|
||||
t1.initialize_copy(t2)
|
||||
assert("initialize_copy") { t1 == t2 }
|
||||
assert("initialize_copy") { t2.clone == t2 }
|
||||
|
||||
report()
|
||||
|
||||
Reference in New Issue
Block a user