Skip to content

Commit ea30bd6

Browse files
committed
8263362: Avoid division by 0 in java/awt/font/TextJustifier.java justify
Reviewed-by: psadhukhan
1 parent 0f9852c commit ea30bd6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/java.desktop/share/classes/java/awt/font/TextJustifier.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -155,10 +155,13 @@ public float[] justify(float delta) {
155155
boolean absorbing = hitLimit && absorbweight > 0;
156156

157157
// predivide delta by weight
158-
float weightedDelta = delta / weight; // not used if weight == 0
158+
float weightedDelta = 0;
159+
if (weight != 0) { // not used if weight == 0
160+
weightedDelta = delta / weight;
161+
}
159162

160163
float weightedAbsorb = 0;
161-
if (hitLimit && absorbweight > 0) {
164+
if (hitLimit && absorbweight != 0) {
162165
weightedAbsorb = (delta - gslimit) / absorbweight;
163166
}
164167

0 commit comments

Comments
 (0)