diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-11-15 08:08:55 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-11-15 08:08:55 +0900 |
| commit | a6119b00778cee2e5621246ee7c63ff48e610e15 (patch) | |
| tree | 015ca48b099b087a65b9c1870c50c39836bca965 /include | |
| parent | bb1fb2f43ddadba8f5687dc4c677f8fb83a2ad8e (diff) | |
| download | mruby-a6119b00778cee2e5621246ee7c63ff48e610e15.tar.gz mruby-a6119b00778cee2e5621246ee7c63ff48e610e15.zip | |
Fixed further wrong condition in overflow detection.
Diffstat (limited to 'include')
| -rw-r--r-- | include/mruby/numeric.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/mruby/numeric.h b/include/mruby/numeric.h index 023d30ffb..683a5b41c 100644 --- a/include/mruby/numeric.h +++ b/include/mruby/numeric.h @@ -68,7 +68,7 @@ MRB_API mrb_value mrb_num_mul(mrb_state *mrb, mrb_value x, mrb_value y); #endif #endif -#if 0 && defined MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS +#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS static inline mrb_bool mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum) @@ -122,7 +122,7 @@ mrb_int_mul_overflow(mrb_int a, mrb_int b, mrb_int *c) #ifdef MRB_INT32 int64_t n = (int64_t)a * b; *c = (mrb_int)n; - return n > MRB_INT_MAX && n < MRB_INT_MIN; + return n > MRB_INT_MAX || n < MRB_INT_MIN; #else /* MRB_INT64 */ if (a > 0 && b > 0 && a > MRB_INT_MAX / b) return TRUE; if (a < 0 && b > 0 && a < MRB_INT_MIN / b) return TRUE; |
