[Android] libvlc: release native string returned from libvlc_media_get_mrl
Martin Finkel
git at videolan.org
Tue Mar 12 10:07:04 CET 2019
vlc-android | branch: master | Martin Finkel <martin at videolabs.io> | Fri Mar 8 16:40:44 2019 +0700| [7c1156f45bc7be659975be6895e419cf03862e2e] | committer: Geoffrey Métais
libvlc: release native string returned from libvlc_media_get_mrl
> https://code.videolan.org/videolan/vlc-android/commit/7c1156f45bc7be659975be6895e419cf03862e2e
---
libvlc/jni/libvlcjni-media.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/libvlc/jni/libvlcjni-media.c b/libvlc/jni/libvlcjni-media.c
index 33ecc5bfa..efcdd7650 100644
--- a/libvlc/jni/libvlcjni-media.c
+++ b/libvlc/jni/libvlcjni-media.c
@@ -356,16 +356,18 @@ jstring
Java_org_videolan_libvlc_Media_nativeGetMrl(JNIEnv *env, jobject thiz)
{
vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);
- const char *psz_mrl;
+ jstring jmrl = NULL;
if (!p_obj)
return NULL;
- psz_mrl = libvlc_media_get_mrl(p_obj->u.p_m);
- if (psz_mrl)
- return (*env)->NewStringUTF(env, psz_mrl);
+ char *psz_mrl = libvlc_media_get_mrl(p_obj->u.p_m);
+ if (psz_mrl) {
+ jmrl = (*env)->NewStringUTF(env, psz_mrl);
+ free(psz_mrl);
+ }
- return NULL;
+ return jmrl;
}
jint
More information about the Android
mailing list