From 968053a35b7cf6a85949efc8eb5f7cb3dab23f67 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 13 Aug 2020 10:21:24 +0900 Subject: Avoid out-of-range error for negative time on `MRB_TIME_T_UINT`. On platforms where `time_t` is unsigned, negative time can be a result of integer casting. Out-of-range error is too strict for those cases. This fix does not address wrong time value in `MRB_WORD_BOXING`. It will be addressed later (by introducing "big" integers). --- mrbgems/mruby-time/src/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c index 621fda42b..8a3abc1c4 100644 --- a/mrbgems/mruby-time/src/time.c +++ b/mrbgems/mruby-time/src/time.c @@ -257,7 +257,7 @@ mrb_to_time_t(mrb_state *mrb, mrb_value obj, time_t *usec) mrb_int i = mrb_int(mrb, obj); if ((MRB_INT_MAX > MRB_TIME_MAX && i > 0 && i > (mrb_int)MRB_TIME_MAX) || - (MRB_TIME_MIN > MRB_INT_MIN && MRB_TIME_MIN > i)) { + (!MRB_TIME_T_UINT && MRB_TIME_MIN > MRB_INT_MIN && MRB_TIME_MIN > i)) { goto out_of_range; } -- cgit v1.2.3