Commit 296c889f authored by Edward Wang's avatar Edward Wang
Browse files

Call DeleteLocalRef() when done with string

This fixes a crash where there are more than 512 files in a folder.
parent fc5b4065
...@@ -966,6 +966,7 @@ void Java_org_videolan_vlc_LibVLC_nativeReadDirectory(JNIEnv *env, jobject thiz, ...@@ -966,6 +966,7 @@ void Java_org_videolan_vlc_LibVLC_nativeReadDirectory(JNIEnv *env, jobject thiz,
jmethodID methodID = (*env)->GetMethodID(env, arrayClass, "add", "(Ljava/lang/Object;)Z"); jmethodID methodID = (*env)->GetMethodID(env, arrayClass, "add", "(Ljava/lang/Object;)Z");
struct dirent* p_dirent; struct dirent* p_dirent;
jstring str;
while(1) { while(1) {
errno = 0; errno = 0;
p_dirent = readdir(p_dir); p_dirent = readdir(p_dir);
...@@ -975,7 +976,9 @@ void Java_org_videolan_vlc_LibVLC_nativeReadDirectory(JNIEnv *env, jobject thiz, ...@@ -975,7 +976,9 @@ void Java_org_videolan_vlc_LibVLC_nativeReadDirectory(JNIEnv *env, jobject thiz,
else if(errno == 0) /* end of stream */ else if(errno == 0) /* end of stream */
break; break;
} }
(*env)->CallBooleanMethod(env, arrayList, methodID, (*env)->NewStringUTF(env, p_dirent->d_name)); str = (*env)->NewStringUTF(env, p_dirent->d_name);
(*env)->CallBooleanMethod(env, arrayList, methodID, str);
(*env)->DeleteLocalRef(env, str);
} }
closedir(p_dir); closedir(p_dir);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment