Dev: fix local reference leak

This commit is contained in:
Andrew Druk 2019-09-24 01:00:31 +03:00
parent 3bd5f9bdab
commit 048b9dd595
1 changed files with 3 additions and 0 deletions

View File

@ -195,6 +195,9 @@ public struct JavaCoderConfig {
return JNI.CallStaticObjectMethod(ByteBufferClass, methodID: ByteBufferWrap, args: [jvalue(l: byteArray)])!
}, decodableClosure: {
let byteArray = JNI.CallObjectMethod($0, methodID: ByteBufferArray)
defer {
JNI.api.DeleteLocalRef(JNI.env, byteArray)
}
guard let pointer = JNI.api.GetByteArrayElements(JNI.env, byteArray, nil) else {
throw JavaCodingError.cantFindObject("ByteBuffer")
}