diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-03-01 11:35:15 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-03-01 11:35:15 +0900 |
| commit | 935a13555391a69b53c4b80b4d014f042b3614ff (patch) | |
| tree | c8632c8d633c05075d7336bcf8e36c667c966e4c /mrbgems | |
| parent | 65add8c650088f398642aa9611baf4cb2266fff4 (diff) | |
| download | mruby-935a13555391a69b53c4b80b4d014f042b3614ff.tar.gz mruby-935a13555391a69b53c4b80b4d014f042b3614ff.zip | |
time.c: fixed a bug on no builtin overflow (e.g. VC).
Diffstat (limited to 'mrbgems')
| -rw-r--r-- | mrbgems/mruby-time/src/time.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c index fcd5902e0..1531348de 100644 --- a/mrbgems/mruby-time/src/time.c +++ b/mrbgems/mruby-time/src/time.c @@ -214,7 +214,7 @@ typedef mrb_int mrb_sec; MRB_TIME_T_UINT ? 0 : \ (sizeof(time_t) <= 4 ? INT32_MIN : INT64_MIN) \ ) -#define MRB_TIME_MAX ( \ +#define MRB_TIME_MAX (time_t)( \ MRB_TIME_T_UINT ? (sizeof(time_t) <= 4 ? UINT32_MAX : UINT64_MAX) : \ (sizeof(time_t) <= 4 ? INT32_MAX : INT64_MAX) \ ) @@ -586,6 +586,7 @@ mrb_time_plus(mrb_state *mrb, mrb_value self) int_overflow(mrb, "addition"); } } + sec = tm->sec + sec; #endif return mrb_time_make_time(mrb, mrb_obj_class(mrb, self), sec, tm->usec+usec, tm->timezone); } @@ -629,6 +630,7 @@ mrb_time_minus(mrb_state *mrb, mrb_value self) int_overflow(mrb, "subtraction"); } } + sec = tm->sec - sec; #endif return mrb_time_make_time(mrb, mrb_obj_class(mrb, self), sec, tm->usec-usec, tm->timezone); } |
