Skip to content

Commit

Permalink
Fix int overflow in ObjectSizeCalculator#increaseByArraySize.
Browse files Browse the repository at this point in the history
  • Loading branch information
jchalou committed Dec 20, 2024
1 parent 137fd0b commit 31a7287
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ private static final class CalculationState {

/**
* Given an object, returns the allocated size, in bytes, of the object and all other objects
* reachable from it within {@link ObjectSizeCalculator#isContextHeapBoundary(Object) context
* heap boundary}.
* reachable from it within {@link ObjectSizeCalculator#isContextHeapBoundary(APIAccess, Object)
* context heap boundary}.
*
* @param obj the object; cannot be null.
* @param stopAtBytes when calculated size exceeds stopAtBytes, calculation stops and returns
Expand Down Expand Up @@ -285,7 +285,7 @@ private static ForcedStop visit(CalculationState calculationState, Object obj) {
}
}

private static void increaseByArraySize(CalculationState calculationState, ArrayMemoryLayout layout, int length) {
private static void increaseByArraySize(CalculationState calculationState, ArrayMemoryLayout layout, long length) {
increaseSize(calculationState, roundToObjectAlignment(layout.baseOffset + length * layout.indexScale, getObjectAlignment()));
}

Expand Down

0 comments on commit 31a7287

Please sign in to comment.