* time.c (long_mul): overflow condition changed.

(wi_mul): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-03-31 19:31:08 +00:00
Родитель d245582dcb
Коммит e758c3fbce
2 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Thu Apr 1 04:30:11 2010 Tanaka Akira <akr@fsij.org>
* time.c (long_mul): overflow condition changed.
(wi_mul): ditto.
Wed Mar 31 23:33:29 2010 Tanaka Akira <akr@fsij.org>
* time.c (long_mul): extracted from mul and avoid integer overflow.

4
time.c
Просмотреть файл

@ -103,8 +103,8 @@ long_mul(long x, long y, long *z)
else {
b = (unsigned long)y;
}
if (a <= ULONG_MAX / b) {
c = a * b;
if (c / b == a) {
if (s < 0) {
if (c <= (unsigned long)LONG_MAX + 1) {
*z = -(long)c;
@ -478,8 +478,8 @@ wi_mul(wideint_t x, wideint_t y, wideint_t *z)
else {
b = (uwideint_t)y;
}
if (a <= UWIDEINT_MAX / b) {
c = a * b;
if (c / b == a) {
if (s < 0) {
if (c <= (uwideint_t)WIDEINT_MAX + 1) {
*z = -(wideint_t)c;