fix incorrect integer-overflow checkups in OP_SUB/OP_SUBI case.

This commit is contained in:
skandhas
2012-12-13 14:42:07 +08:00
parent 35abbd1486
commit 6dede4edf9
+2 -2
View File
@@ -1390,7 +1390,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
x = mrb_fixnum(regs[a]);
y = mrb_fixnum(regs[a+1]);
z = x - y;
if (((x < 0) ^ (y < 0)) == 0 && (x < 0) != (z < 0)) {
if (((x < 0) ^ (y < 0)) != 0 && (x < 0) != (z < 0)) {
/* integer overflow */
SET_FLT_VALUE(regs[a], (mrb_float)x - (mrb_float)y);
break;
@@ -1532,7 +1532,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
mrb_int y = GETARG_C(i);
mrb_int z = x - y;
if (((x < 0) ^ (y < 0)) == 0 && (x < 0) != (z < 0)) {
if (((x < 0) ^ (y < 0)) != 0 && (x < 0) != (z < 0)) {
/* integer overflow */
SET_FLT_VALUE(regs[a], (mrb_float)x - (mrb_float)y);
break;