Skip to content

Commit

Permalink
8263362: Avoid division by 0 in java/awt/font/TextJustifier.java justify
Browse files Browse the repository at this point in the history
Reviewed-by: psadhukhan
  • Loading branch information
MBaesken committed May 6, 2021
1 parent 0f9852c commit ea30bd6
Showing 1 changed file with 6 additions and 3 deletions.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -155,10 +155,13 @@ public float[] justify(float delta) {
boolean absorbing = hitLimit && absorbweight > 0; boolean absorbing = hitLimit && absorbweight > 0;


// predivide delta by weight // predivide delta by weight
float weightedDelta = delta / weight; // not used if weight == 0 float weightedDelta = 0;
if (weight != 0) { // not used if weight == 0
weightedDelta = delta / weight;
}


float weightedAbsorb = 0; float weightedAbsorb = 0;
if (hitLimit && absorbweight > 0) { if (hitLimit && absorbweight != 0) {
weightedAbsorb = (delta - gslimit) / absorbweight; weightedAbsorb = (delta - gslimit) / absorbweight;
} }


Expand Down

3 comments on commit ea30bd6

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on ea30bd6 Aug 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MBaesken the backport was successfully created on the branch MBaesken-backport-ea30bd66 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit ea30bd66 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 6 May 2021 and was reviewed by Prasanta Sadhukhan.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev MBaesken-backport-ea30bd66:MBaesken-backport-ea30bd66
$ git checkout MBaesken-backport-ea30bd66
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev MBaesken-backport-ea30bd66

Please sign in to comment.