From c0adc9a81e4735bfd5bfbf099bcbcc4a6eb27004 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 23 May 2014 10:35:44 -0600 Subject: [PATCH] don't use GetPrimitiveArrayCritical when throwing SocketExceptions 690ba9c fixed this for throwIOException, but we didn't notice that throwSocketException had the same problem. --- classpath/java-nio.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/classpath/java-nio.cpp b/classpath/java-nio.cpp index 0a8a1bcf36..065e8a45ff 100644 --- a/classpath/java-nio.cpp +++ b/classpath/java-nio.cpp @@ -143,9 +143,15 @@ throwSocketException(JNIEnv* e, const char* s) void throwSocketException(JNIEnv* e, jbyteArray a) { - jbyte* s = static_cast(e->GetPrimitiveArrayCritical(a, 0)); - throwSocketException(e, reinterpret_cast(s)); - e->ReleasePrimitiveArrayCritical(a, s, 0); + size_t length = e->GetArrayLength(a); + uint8_t* buf = static_cast(allocate(e, length)); + if (buf) { + e->GetByteArrayRegion(a, 0, length, reinterpret_cast(buf)); + throwSocketException(e, reinterpret_cast(buf)); + free(buf); + } else { + return; + } } void