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

Rectangle methods should protect against overflow conditions where possible

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 6
    • 1.2.1, 1.4.2, 6
    • client-libs
    • None
    • 2d
    • b86
    • generic, sparc
    • generic, solaris_2.6

      Several of the Rectangle methods do not protect properly against integer
      overflow.

      In earlier releases a few of the hit testing methods were upgraded to
      perform their calculations in a way that avoids integer overflow. See
      bugs 4280606, 4394562, 4394565, and 4394579 for more information on the
      earlier overflow work.

      This unfortunately leaves several of the other methods that modify the
      rectangle still suffering from potential overflow conditions. Bug 4491273
      was submitted to request a documentation update to reflect the overflow
      possibilities, but it was decided by the engineering team to instead fix
      as many of the overflow possibilities as could be fixed within the constraints
      of the fact that the data is stored in exposed integer fields. The remaining
      limits imposed by the 32-bit integer storage would then be documented. The
      methods that are being modified are:

      setRect(double, double, double, double)
      translate(int, int)
      union(Rectangle)
      add(int, int)
      add(Rectangle)
      grow(int, int)

      These methods need to store their results into a Rectangle object and so are
      constrained in the final answer by the 32-bit integer range, but they can at
      least protect against overflow during their intermediate calculations.

            flar Jim Graham
            flar Jim Graham
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: