mruby-struct/struct.c: update the behavior when actual size differs

Assertions may be false and terminate the whole process when actual size
for struct objects are different.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-05-25 08:45:47 +09:00
parent f50e40f291
commit e05ac91217
+6 -2
View File
@@ -524,7 +524,9 @@ mrb_struct_equal(mrb_state *mrb, mrb_value s)
if (mrb_obj_class(mrb, s) != mrb_obj_class(mrb, s2)) {
return mrb_false_value();
}
mrb_assert(RSTRUCT_LEN(s) == RSTRUCT_LEN(s2));
if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) {
return mrb_false_value();
}
ptr = RSTRUCT_PTR(s);
ptr2 = RSTRUCT_PTR(s2);
len = RSTRUCT_LEN(s);
@@ -558,7 +560,9 @@ mrb_struct_eql(mrb_state *mrb, mrb_value s)
if (mrb_obj_class(mrb, s) != mrb_obj_class(mrb, s2)) {
return mrb_false_value();
}
mrb_assert(RSTRUCT_LEN(s) == RSTRUCT_LEN(s2));
if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) {
return mrb_false_value();
}
ptr = RSTRUCT_PTR(s);
ptr2 = RSTRUCT_PTR(s2);
len = RSTRUCT_LEN(s);