• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

mrubyを超漢字で動作させる


Commit MetaInfo

修訂e749267909f879ac3e8b8cf681c2c6067d056a96 (tree)
時間2014-07-02 10:28:10
作者Yukihiro "Matz" Matsumoto <matz@ruby...>
CommiterYukihiro "Matz" Matsumoto

Log Message

time overflow check; ref #2337

Change Summary

差異

--- a/mrbgems/mruby-time/src/time.c
+++ b/mrbgems/mruby-time/src/time.c
@@ -201,6 +201,13 @@ time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezone)
201201
202202 tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(struct mrb_time));
203203 tm->sec = (time_t)sec;
204+ if (sizeof(time_t) == 4 && (sec > (double)INT32_MAX || (double)INT32_MIN > sec)) {
205+ goto out_of_range;
206+ }
207+ else if ((sec > 0 && tm->sec < 0) || (sec < 0 && (double)tm->sec > sec)) {
208+ out_of_range:
209+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "%S out of Time range", mrb_float_value(mrb, sec));
210+ }
204211 tm->usec = (time_t)((sec - tm->sec) * 1.0e6 + usec);
205212 while (tm->usec < 0) {
206213 tm->sec--;