Skip to content

Commit

Permalink
8280459: Suspicious integer division in Hashtable.readHashtable
Browse files Browse the repository at this point in the history
Reviewed-by: rriggs, bpb
  • Loading branch information
shipilev committed Jan 24, 2022
1 parent 9bf6ffa commit d156911
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/util/Hashtable.java
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ void readHashtable(ObjectInputStream s)
// no larger than the clamped original length. Make the length
// odd if it's large enough, this helps distribute the entries.
// Guard against the length ending up zero, that's not valid.
int length = (int)((elements + elements / 20) / lf) + 3;
int length = (int)(elements * 1.05f / lf) + 3;
if (length > elements && (length & 1) == 0)
length--;
length = Math.min(length, origlength);
Expand Down

1 comment on commit d156911

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.