Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
e7492679
Commit
e7492679
authored
Jul 02, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time overflow check; ref #2337
parent
ad502775
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
mrbgems/mruby-time/src/time.c
mrbgems/mruby-time/src/time.c
+7
-0
No files found.
mrbgems/mruby-time/src/time.c
View file @
e7492679
...
...
@@ -201,6 +201,13 @@ time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezone)
tm
=
(
struct
mrb_time
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_time
));
tm
->
sec
=
(
time_t
)
sec
;
if
(
sizeof
(
time_t
)
==
4
&&
(
sec
>
(
double
)
INT32_MAX
||
(
double
)
INT32_MIN
>
sec
))
{
goto
out_of_range
;
}
else
if
((
sec
>
0
&&
tm
->
sec
<
0
)
||
(
sec
<
0
&&
(
double
)
tm
->
sec
>
sec
))
{
out_of_range:
mrb_raisef
(
mrb
,
E_ARGUMENT_ERROR
,
"%S out of Time range"
,
mrb_float_value
(
mrb
,
sec
));
}
tm
->
usec
=
(
time_t
)((
sec
-
tm
->
sec
)
*
1.0e6
+
usec
);
while
(
tm
->
usec
<
0
)
{
tm
->
sec
--
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment