Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8272541

Incorrect overflow test in Toom-Cook branch of BigInteger multiplication

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 11, 17, 18
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b13
    • CPU:
      generic
    • OS:
      generic

      Description

      In this code

      if (bitLength(mag, mag.length) +
         bitLength(val.mag, val.mag.length) >
         32L*MAX_MAG_LENGTH) {
         reportOverflow();
      }

      In the above, bitLength() returns 'int', hence the left operand of the '>' comparison is 'int' too, but the right operand of the '>' comparison is 'long' with value == Integer.MAX_VALUE + 1 hence this condition is always false.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bpb Brian Burkhalter
              Reporter:
              bpb Brian Burkhalter
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: