| Fix incorrect overflow test, that itself overflowed. |
| |
| "(unsigned long)(x * y)" will multiply ints x and y into a new int, then |
| converts the int into an unsigned long. Replace it with |
| "(unsigned long)(x) * (unsigned long)(y)" which performs the multiplication in a |
| larger space. |
| |
| Converted from cl/147088677. |
| |
| --- a/mpn/generic/get_d.c |
| +++ b/mpn/generic/get_d.c |
| @@ -151,8 +151,8 @@ mpn_get_d (mp_srcptr up, mp_size_t size, |
| /* Adjust exp to a radix point just above {up,size}, guarding against |
| overflow. After this exp can of course be reduced to anywhere within |
| the {up,size} region without underflow. */ |
| - if (UNLIKELY ((unsigned long) (GMP_NUMB_BITS * size) |
| - > ((unsigned long) LONG_MAX - exp))) |
| + if (UNLIKELY ((unsigned long) (GMP_NUMB_BITS) * (unsigned long) (size) |
| + > (LONG_MAX - (unsigned long) exp))) |
| { |
| #if _GMP_IEEE_FLOATS |
| goto ieee_infinity; |