summaryrefslogtreecommitdiff
path: root/runtime/jni_internal.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/jni_internal.cc')
-rw-r--r--runtime/jni_internal.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index 513b4092de..2fadfb0f6a 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -2447,13 +2447,18 @@ class JNI {
static jobject NewDirectByteBuffer(JNIEnv* env, void* address, jlong capacity) {
if (capacity < 0) {
JniAbortF("NewDirectByteBuffer", "negative buffer capacity: %" PRId64, capacity);
+ return nullptr;
}
if (address == nullptr && capacity != 0) {
JniAbortF("NewDirectByteBuffer", "non-zero capacity for nullptr pointer: %" PRId64, capacity);
+ return nullptr;
}
- // At the moment, the capacity is limited to 32 bits.
- CHECK_LE(capacity, 0xffffffff);
+ // At the moment, the capacity is limited to a jint (31 bits).
+ if (capacity > INT_MAX) {
+ JniAbortF("NewDirectByteBuffer", "buffer capacity greater than maximum jint: %" PRId64, capacity);
+ return nullptr;
+ }
jlong address_arg = reinterpret_cast<jlong>(address);
jint capacity_arg = static_cast<jint>(capacity);