[Android] Call DeleteLocalRef() when done with string

Edward Wang git at videolan.org
Sun Jul 1 23:46:49 CEST 2012


android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sun Jul  1 17:45:27 2012 -0400| [296c889f2095a7ea68c262e75880fe82530ff696] | committer: Edward Wang

Call DeleteLocalRef() when done with string

This fixes a crash where there are more than 512 files in a folder.

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=296c889f2095a7ea68c262e75880fe82530ff696
---

 vlc-android/jni/libvlcjni.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index 4044cee..1d07a82 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -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");
 
     struct dirent* p_dirent;
+    jstring str;
     while(1) {
         errno = 0;
         p_dirent = readdir(p_dir);
@@ -975,7 +976,9 @@ void Java_org_videolan_vlc_LibVLC_nativeReadDirectory(JNIEnv *env, jobject thiz,
             else if(errno == 0) /* end of stream */
                 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);
 }



More information about the Android mailing list