mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8289365: SegmentAllocator:allocateArray(MemoryLayout, count) does not throw IAEx when count is -1
Reviewed-by: psandoz
This commit is contained in:
parent
0fd1b68972
commit
4545ed6842
2 changed files with 8 additions and 0 deletions
|
@ -319,6 +319,9 @@ public interface SegmentAllocator {
|
|||
*/
|
||||
default MemorySegment allocateArray(MemoryLayout elementLayout, long count) {
|
||||
Objects.requireNonNull(elementLayout);
|
||||
if (count < 0) {
|
||||
throw new IllegalArgumentException("Negative array size");
|
||||
}
|
||||
return allocate(MemoryLayout.sequenceLayout(count, elementLayout));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue