mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-09 00:14:04 +00:00
Fixed bounds checking to work with .sliced mapped objects.
This commit is contained in:
parent
585549f1f1
commit
fa31e0f9cb
2 changed files with 19 additions and 2 deletions
|
|
@ -89,17 +89,34 @@ public class MappedObjectTests1 {
|
|||
vecs.view = 0;
|
||||
}
|
||||
|
||||
// test bound check
|
||||
// test bounds checking
|
||||
{
|
||||
assert (vecs.view == 0);
|
||||
try {
|
||||
vecs.view = 49;
|
||||
assert vecs.view == 49;
|
||||
vecs.view = 0;
|
||||
vecs.view = 50;
|
||||
System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
|
||||
vecs.view = 0;
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
// expected, ignore
|
||||
}
|
||||
|
||||
assert (vecs.view == 0);
|
||||
|
||||
try {
|
||||
vecs.view = 10;
|
||||
MappedFloat vecs2 = vecs.slice();
|
||||
vecs.view = 0;
|
||||
|
||||
vecs2.view = 39;
|
||||
assert vecs2.view == 39;
|
||||
vecs2.view = 40;
|
||||
System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
// expected, ignore
|
||||
}
|
||||
}
|
||||
|
||||
// test dup
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class MappedObject {
|
|||
}
|
||||
|
||||
final void checkAddress(final long address) {
|
||||
if ( preventGC.capacity() < (address + stride - baseAddress) )
|
||||
if ( preventGC.capacity() < (address - MappedObjectUnsafe.getBufferBaseAddress(preventGC) + stride) )
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue