1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* time.c (wdiv, wmod): wdivmod0() assumes the 3rd and the 4th arguments

are valid pointers.
  maybe checking them in wdivmod0() is better manner, but I guess that
  passing real dummy pointers may be faster than checking and branching
  in wdivmod0().
  this commit fixes SEGV on 32bit and LLP64 platforms.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2016-03-22 01:37:01 +00:00
parent 0dbbcdb6bb
commit 6957898ad0
2 changed files with 13 additions and 4 deletions

View file

@ -1,3 +1,12 @@
Tue Mar 22 10:31:34 2016 NAKAMURA Usaku <usa@ruby-lang.org>
* time.c (wdiv, wmod): wdivmod0() assumes the 3rd and the 4th arguments
are valid pointers.
maybe checking them in wdivmod0() is better manner, but I guess that
passing real dummy pointers may be faster than checking and branching
in wdivmod0().
this commit fixes SEGV on 32bit and LLP64 platforms.
Tue Mar 22 10:24:04 2016 NAKAMURA Usaku <usa@ruby-lang.org>
* time.c (divmodv): void function never returns any value.

8
time.c
View file

@ -461,8 +461,8 @@ static wideval_t
wdiv(wideval_t wx, wideval_t wy)
{
#if WIDEVALUE_IS_WIDER
wideval_t q;
if (wdivmod0(wx, wy, &q, NULL)) return q;
wideval_t q, dmy;
if (wdivmod0(wx, wy, &q, &dmy)) return q;
#endif
return v2w(div(w2v(wx), w2v(wy)));
}
@ -471,8 +471,8 @@ static wideval_t
wmod(wideval_t wx, wideval_t wy)
{
#if WIDEVALUE_IS_WIDER
wideval_t r;
if (wdivmod0(wx, wy, NULL, &r)) return r;
wideval_t r, dmy;
if (wdivmod0(wx, wy, &dmy, &r)) return r;
#endif
return v2w(mod(w2v(wx), w2v(wy)));
}