Skip to content
Permalink
Browse files
8263362: Avoid division by 0 in java/awt/font/TextJustifier.java justify
Backport-of: ea30bd6
  • Loading branch information
MBaesken committed Sep 1, 2021
1 parent 0ea1e0f commit d41b37ff9f5af31796b36825b5e266afd4b99a18
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/java.desktop/share/classes/java/awt/font/TextJustifier.java
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@@ -155,10 +155,13 @@
boolean absorbing = hitLimit && absorbweight > 0;

// 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;
if (hitLimit && absorbweight > 0) {
if (hitLimit && absorbweight != 0) {
weightedAbsorb = (delta - gslimit) / absorbweight;
}

1 comment on commit d41b37f

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on d41b37f Sep 1, 2021

Please sign in to comment.