Re: [OpenJDK 2D-Dev] RFR: JDK-8263362: Avoid division by 0 in java/awt/font/TextJustifier.java justify [v2]
On Wed, 5 May 2021 14:11:16 GMT, Matthias Baesken wrote: >> In java/awt/font/TextJustifier.java justify-method 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=AXcqMwpm8sPJZZzONu1k=false=CRITICAL=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. > > Matthias Baesken has updated the pull request incrementally with one > additional commit since the last revision: > > adjust absorbweight check Marked as reviewed by psadhukhan (Reviewer). - PR: https://git.openjdk.java.net/jdk/pull/2912
Re: [OpenJDK 2D-Dev] RFR: JDK-8263362: Avoid division by 0 in java/awt/font/TextJustifier.java justify [v2]
> In java/awt/font/TextJustifier.java justify-method 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=AXcqMwpm8sPJZZzONu1k=false=CRITICAL=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. Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision: adjust absorbweight check - Changes: - all: https://git.openjdk.java.net/jdk/pull/2912/files - new: https://git.openjdk.java.net/jdk/pull/2912/files/6b31126f..4e21791e Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=2912=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk=2912=00-01 Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod Patch: https://git.openjdk.java.net/jdk/pull/2912.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/2912/head:pull/2912 PR: https://git.openjdk.java.net/jdk/pull/2912