Commit cdab2dbf authored by Philippe Morin's avatar Philippe Morin

Add input check.

Avoid mallocing/freeing a libvlc_exception_t (end).
parent 2f29e4ff
...@@ -54,9 +54,9 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env, ...@@ -54,9 +54,9 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env,
int argc; int argc;
const char **argv; const char **argv;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) ); libvlc_exception_t exception;
libvlc_exception_init( exception ); libvlc_exception_init( &exception );
argc = (int) env->GetArrayLength((jarray) args); argc = (int) env->GetArrayLength((jarray) args);
argv = (const char **) malloc(argc * sizeof(char*)); argv = (const char **) malloc(argc * sizeof(char*));
...@@ -67,9 +67,9 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env, ...@@ -67,9 +67,9 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env,
); );
} }
res = (long) libvlc_new(argc, (char**) argv, exception ); res = (long) libvlc_new(argc, (char**) argv, &exception );
free( exception ); CHECK_EXCEPTION ;
return res; return res;
......
...@@ -24,9 +24,7 @@ ...@@ -24,9 +24,7 @@
*****************************************************************************/ *****************************************************************************/
#include <jni.h> #include <jni.h>
#include <vlc/libvlc.h> #include <vlc/libvlc.h>
/* JVLC internal imports, generated by gcjh */ /* JVLC internal imports, generated by gcjh */
#include "../includes/Input.h" #include "../includes/Input.h"
#include "utils.h" #include "utils.h"
...@@ -117,7 +115,11 @@ JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Input__1isPlaying (JNIEnv *env ...@@ -117,7 +115,11 @@ JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Input__1isPlaying (JNIEnv *env
vlc_bool_t res = 0; vlc_bool_t res = 0;
GET_INPUT_THREAD ; GET_INPUT_THREAD ;
if (input == NULL) {
return false;
}
res = libvlc_media_instance_will_play( input, &exception ); res = libvlc_media_instance_will_play( input, &exception );
libvlc_media_instance_release(input); libvlc_media_instance_release(input);
CHECK_EXCEPTION ; CHECK_EXCEPTION ;
...@@ -132,6 +134,9 @@ JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Input__1hasVout (JNIEnv *env, ...@@ -132,6 +134,9 @@ JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Input__1hasVout (JNIEnv *env,
GET_INPUT_THREAD ; GET_INPUT_THREAD ;
if (input == NULL) {
return false;
}
res = libvlc_media_instance_has_vout( input, &exception ); res = libvlc_media_instance_has_vout( input, &exception );
libvlc_media_instance_release(input); libvlc_media_instance_release(input);
CHECK_EXCEPTION ; CHECK_EXCEPTION ;
......
Markdown is supported
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