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

Avoid division by 0 in java/awt/font/TextJustifier.java justify

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      b22
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        In java/awt/font/TextJustifier.java justify there is a potential code path where divison by zero might happen , see also the Sonar finding :

        https://sonarcloud.io/project/issues?id=shipilev_jdk&open=AXcqMwpm8sPJZZzONu1k&resolved=false&severities=CRITICAL&types=BUG


                    boolean hitLimit = (weight == 0) || (!lastPass && ((delta < 0) == (delta < gslimit)));
                    boolean absorbing = hitLimit && absorbweight > 0;
                    // predivide delta by weight
                    float weightedDelta = delta / weight; // not used if weight == 0

        In case of (weight == 0) the division should not be done because the value of weightedDelta is unused in this case anyway.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                mbaesken Matthias Baesken
                Reporter:
                mbaesken Matthias Baesken
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: