Skip to content

Commit

Permalink
Promote to long before shifting when computing array size
Browse files Browse the repository at this point in the history
(cherry picked from commit 463949b)
  • Loading branch information
tkrodriguez authored and marwan-hallaoui committed Oct 3, 2023
1 parent fcb8daf commit f278cb7
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected UnsignedWord arrayAllocationSize(int length, int arrayBaseOffset, int
* We do an unsigned multiplication so that a negative array length will result in an array size
* greater than Integer.MAX_VALUE.
*/
public static long arrayAllocationSize(int length, int arrayBaseOffset, int log2ElementSize, int alignment) {
public static long arrayAllocationSize(long length, int arrayBaseOffset, int log2ElementSize, int alignment) {
long size = ((length & 0xFFFFFFFFL) << log2ElementSize) + arrayBaseOffset + (alignment - 1);
long mask = ~(alignment - 1);
return size & mask;
Expand Down

0 comments on commit f278cb7

Please sign in to comment.