Browse Source

fix datastore get call in JNI

Just delete the local reference rather than do an array delete.  Array delete was causing a crash on loading network config files.  Deleting the local ref works fine, though, as it still lets the JVM garbage collecter know that the native code is done with the array
Grant Limberg 10 năm trước cách đây
mục cha
commit
09631ad382
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      java/jni/com_zerotierone_sdk_Node.cpp

+ 3 - 3
java/jni/com_zerotierone_sdk_Node.cpp

@@ -333,10 +333,10 @@ namespace {
 
         if(retval > 0)
         {
-            env->GetByteArrayRegion(bufferObj, 0, bufferSize, (jbyte*)buffer);
+            env->GetByteArrayRegion(bufferObj, 0, retval, (jbyte*)buffer);
             env->GetLongArrayRegion(objectSizeObj, 0, 1, (jlong*)out_objectSize);
-            env->ReleaseByteArrayElements(bufferObj, (jbyte*)buffer, 0);
-            env->ReleaseLongArrayElements(objectSizeObj, (jlong*)out_objectSize, 0);
+            env->DeleteLocalRef(bufferObj);
+            env->DeleteLocalRef(objectSizeObj);
         }
 
         LOGI("Out Object Size: %lu", *out_objectSize);