mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8296024: Usage of DirectBuffer::address should be guarded
Reviewed-by: mcimadamore, alanb, psandoz, bpb
This commit is contained in:
parent
a9e6c62ba7
commit
84b927a05b
24 changed files with 635 additions and 430 deletions
|
@ -24,7 +24,6 @@
|
|||
*/
|
||||
package java.util.zip;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
|
@ -33,6 +32,8 @@ import jdk.internal.util.Preconditions;
|
|||
import jdk.internal.vm.annotation.IntrinsicCandidate;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
import static java.util.zip.ZipUtils.NIO_ACCESS;
|
||||
|
||||
/**
|
||||
* A class that can be used to compute the CRC-32C of a data stream.
|
||||
*
|
||||
|
@ -171,11 +172,12 @@ public final class CRC32C implements Checksum {
|
|||
}
|
||||
|
||||
if (buffer.isDirect()) {
|
||||
NIO_ACCESS.acquireSession(buffer);
|
||||
try {
|
||||
crc = updateDirectByteBuffer(crc, ((DirectBuffer) buffer).address(),
|
||||
crc = updateDirectByteBuffer(crc, ((DirectBuffer)buffer).address(),
|
||||
pos, limit);
|
||||
} finally {
|
||||
Reference.reachabilityFence(buffer);
|
||||
NIO_ACCESS.releaseSession(buffer);
|
||||
}
|
||||
} else if (buffer.hasArray()) {
|
||||
crc = updateBytes(crc, buffer.array(), pos + buffer.arrayOffset(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue