mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8288761: SegmentAllocator:allocate(long bytesSize) not throwing IAEx when bytesSize < 0
Reviewed-by: psandoz
This commit is contained in:
parent
834d92dd72
commit
d7b43af591
5 changed files with 46 additions and 16 deletions
|
@ -883,9 +883,7 @@ public sealed interface MemorySegment extends Addressable permits AbstractMemory
|
|||
Reflection.ensureNativeAccess(Reflection.getCallerClass(), MemorySegment.class, "ofAddress");
|
||||
Objects.requireNonNull(address);
|
||||
Objects.requireNonNull(session);
|
||||
if (bytesSize < 0) {
|
||||
throw new IllegalArgumentException("Invalid size : " + bytesSize);
|
||||
}
|
||||
Utils.checkAllocationSizeAndAlign(bytesSize, 1);
|
||||
return NativeMemorySegmentImpl.makeNativeSegmentUnchecked(address, bytesSize, session);
|
||||
}
|
||||
|
||||
|
@ -957,15 +955,7 @@ public sealed interface MemorySegment extends Addressable permits AbstractMemory
|
|||
*/
|
||||
static MemorySegment allocateNative(long bytesSize, long alignmentBytes, MemorySession session) {
|
||||
Objects.requireNonNull(session);
|
||||
if (bytesSize < 0) {
|
||||
throw new IllegalArgumentException("Invalid allocation size : " + bytesSize);
|
||||
}
|
||||
|
||||
if (alignmentBytes <= 0 ||
|
||||
((alignmentBytes & (alignmentBytes - 1)) != 0L)) {
|
||||
throw new IllegalArgumentException("Invalid alignment constraint : " + alignmentBytes);
|
||||
}
|
||||
|
||||
Utils.checkAllocationSizeAndAlign(bytesSize, alignmentBytes);
|
||||
return NativeMemorySegmentImpl.makeNativeSegment(bytesSize, alignmentBytes, session);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue