[Android] libvlc: fix media leak in legacy code

Thomas Guillem git at videolan.org
Tue Jan 20 12:05:47 CET 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jan 15 18:37:13 2015 +0100| [f4f7123b5eed15231d54dfa89ddeead51a3d9675] | committer: Thomas Guillem

libvlc: fix media leak in legacy code

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

 libvlc/jni/libvlcjni.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index 6e65c35..27d4e06 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -709,6 +709,7 @@ jstring Java_org_videolan_libvlc_LibVLC_getMeta(JNIEnv *env, jobject thiz, int m
         string = (*env)->NewStringUTF(env, psz_meta);
         free(psz_meta);
     }
+    libvlc_media_release(p_mp);
     return string;
 }
 
@@ -784,10 +785,17 @@ static int expand_media_internal(JNIEnv *env, libvlc_instance_t* p_instance, job
 }
 
 jint Java_org_videolan_libvlc_LibVLC_expandMedia(JNIEnv *env, jobject thiz, jobject children) {
-    return (jint)expand_media_internal(env,
+    jint ret;
+    libvlc_media_t *p_md = libvlc_media_player_get_media(getMediaPlayer(env, thiz));
+
+    if (!p_md)
+        return -1;
+    ret = (jint)expand_media_internal(env,
         getLibVlcInstance(env, thiz),
         children,
-        (libvlc_media_t*)libvlc_media_player_get_media(getMediaPlayer(env, thiz)));
+        p_md);
+    libvlc_media_release(p_md);
+    return ret;
 }
 
 // TODO: remove static variables



More information about the Android mailing list