Skip to content

Commit 8ba48e8

Browse files
authored
ANDROID: do not call ReleaseStringUTFChars with an unrelated pointer (#397)
1 parent b9e86be commit 8ba48e8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

loaders/android/bootstrap.c.in

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ static const char* app_directory_files = NULL;
6666
static const char* app_code_path = NULL;
6767

6868
void Java_@SYS_PACKAGE_UNDERSCORE@_@SYS_APPNAME@_nativeInstanceInit(JNIEnv* env, jobject thiz, jstring codePath, jstring directoryFiles){
69+
const char* tmp;
6970
globalObj = (*env)->NewGlobalRef(env,thiz);
70-
app_directory_files = strdup((*env)->GetStringUTFChars(env, directoryFiles, 0));
71-
(*env)->ReleaseStringUTFChars(env, directoryFiles, app_directory_files);
72-
app_code_path = strdup((*env)->GetStringUTFChars(env, codePath, 0));
73-
(*env)->ReleaseStringUTFChars(env, codePath, app_code_path);
71+
tmp = (*env)->GetStringUTFChars(env, directoryFiles, 0);
72+
app_directory_files = strdup(tmp);
73+
(*env)->ReleaseStringUTFChars(env, directoryFiles, tmp);
74+
tmp = (*env)->GetStringUTFChars(env, codePath, 0);
75+
app_code_path = strdup(tmp);
76+
(*env)->ReleaseStringUTFChars(env, codePath, tmp);
7477
}
7578

7679
char* android_getFilesDir() {

0 commit comments

Comments
 (0)