summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-08-13 10:21:24 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:21:37 +0900
commit968053a35b7cf6a85949efc8eb5f7cb3dab23f67 (patch)
tree71e992a0fba9f5bda37409289325dd42ec1a4ecf
parent66114f8332c734c6fb241803ca301f2ce0da1838 (diff)
downloadmruby-968053a35b7cf6a85949efc8eb5f7cb3dab23f67.tar.gz
mruby-968053a35b7cf6a85949efc8eb5f7cb3dab23f67.zip
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).
-rw-r--r--mrbgems/mruby-time/src/time.c2
1 files changed, 1 insertions, 1 deletions
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;
}