Skip to content

Commit c3ad74d

Browse files
authored
fix get length of byte[]
1 parent 6be33bb commit c3ad74d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

c/src/main/cpp/jni_wrapper.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ void TryCopyLastError(JNIEnv* env, InnerPrivateData* private_data) {
205205
return;
206206
}
207207

208+
jsize error_bytes_len = env->GetArrayLength(arr);
208209
char* error_str = reinterpret_cast<char*>(error_bytes);
209-
private_data->last_error_ = std::string(error_str, std::strlen(error_str));
210+
private_data->last_error_ = std::string(error_str, error_bytes_len);
210211

211212
env->ReleaseByteArrayElements(arr, error_bytes, JNI_ABORT);
212213
}

0 commit comments

Comments
 (0)