mirror of
https://github.com/fumiama/android-base16384.git
synced 2026-06-05 18:20:32 +08:00
v3.2
1. 修复指针越界 2. 修复整数溢出 3. 修复内存泄漏
This commit is contained in:
@@ -14,14 +14,13 @@
|
||||
}
|
||||
|
||||
#define exe_byte(fun) {\
|
||||
uint32_t len = env->GetArrayLength(buf);\
|
||||
jsize len = env->GetArrayLength(buf);\
|
||||
const uint8_t* data = (uint8_t*)env->GetByteArrayElements(buf, JNI_FALSE);\
|
||||
LENDAT* ld = fun(data, len);\
|
||||
jbyteArray out = env->NewByteArray(ld->len);\
|
||||
auto out_data = env->GetByteArrayElements(out, JNI_FALSE);\
|
||||
memcpy(out_data, ld->data, ld->len);\
|
||||
env->SetByteArrayRegion(out, 0, ld->len, reinterpret_cast<const jbyte *>(ld->data));\
|
||||
free(ld->data);\
|
||||
free(ld);\
|
||||
env->ReleaseByteArrayElements(out, out_data, JNI_COMMIT);\
|
||||
return out;\
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user