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 years ago
parent
commit
09631ad382
1 changed files with 3 additions and 3 deletions
  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);