[Android] aout: free dangling global reference

Edward Wang git at videolan.org
Fri Dec 26 01:13:09 CET 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Dec 25 19:06:16 2014 -0500| [b01969a4bfe1b2fa4580f5e8df08dc29566d7a16] | committer: Edward Wang

aout: free dangling global reference

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=b01969a4bfe1b2fa4580f5e8df08dc29566d7a16
---

 libvlc/jni/aout.c      |    1 +
 libvlc/jni/libvlcjni.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libvlc/jni/aout.c b/libvlc/jni/aout.c
index af13111..7d4d8ce 100644
--- a/libvlc/jni/aout.c
+++ b/libvlc/jni/aout.c
@@ -243,6 +243,7 @@ void aout_close(void *opaque)
     }
 
     (*p_env)->DeleteGlobalRef (p_env, p_sys->buffer);
+    (*p_env)->DeleteGlobalRef (p_env, p_sys->j_libVlc);
     jni_detach_thread ();
     free (p_sys);
 }
diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index 1242e3b..73ad04d 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -417,9 +417,9 @@ void Java_org_videolan_libvlc_LibVLC_playMRL(JNIEnv *env, jobject thiz,
     /* Create a media player playing environment */
     libvlc_media_player_t *mp = libvlc_media_player_new(p_instance);
     libvlc_media_player_set_video_title_display(mp, libvlc_position_disable, 0);
-    jobject myJavaLibVLC = (*env)->NewGlobalRef(env, thiz);
+    jobject myJavaLibVLC = (*env)->NewGlobalRef(env, thiz); // freed in aout_close
 
-    //if AOUT_AUDIOTRACK_JAVA, we use amem
+    // If AOUT_AUDIOTRACK_JAVA, use amem
     jclass cls = (*env)->GetObjectClass(env, thiz);
     jmethodID methodId = (*env)->GetMethodID(env, cls, "getAout", "()I");
     if ( (*env)->CallIntMethod(env, thiz, methodId) == AOUT_AUDIOTRACK_JAVA )



More information about the Android mailing list