8289228: SegmentAllocator::allocateArray null handling is too lax

Reviewed-by: jvernee, psandoz
This commit is contained in:
Maurizio Cimadamore 2022-06-28 10:06:42 +00:00
parent b4490386fe
commit adbd200dc5
2 changed files with 3 additions and 16 deletions

View file

@ -282,8 +282,9 @@ public interface SegmentAllocator {
private <Z> MemorySegment copyArrayWithSwapIfNeeded(Z array, ValueLayout elementLayout,
Function<Z, MemorySegment> heapSegmentFactory) {
Objects.requireNonNull(array);
Objects.requireNonNull(elementLayout);
int size = array == null ? 0 : Array.getLength(array);
int size = Array.getLength(array);
MemorySegment addr = allocateArray(elementLayout, size);
if (size > 0) {
MemorySegment.copy(heapSegmentFactory.apply(array), elementLayout, 0,