]> git.sesse.net Git - vlc/commitdiff
Add input check.
authorPhilippe Morin <phmo95@videolan.org>
Thu, 19 Jul 2007 12:57:50 +0000 (12:57 +0000)
committerPhilippe Morin <phmo95@videolan.org>
Thu, 19 Jul 2007 12:57:50 +0000 (12:57 +0000)
Avoid mallocing/freeing a libvlc_exception_t (end).

bindings/java/src/core-jni.cc
bindings/java/src/input-jni.cc

index 6f103aaf94863ebe8703c43a3b14c406d643a90f..91888aa7d2ab952569604c353b78b2e571da230a 100644 (file)
@@ -54,9 +54,9 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env,
     int argc;
     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);
     argv = (const char **) malloc(argc * sizeof(char*));
@@ -67,9 +67,9 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env,
         );
     }
 
-    res = (long) libvlc_new(argc, (char**) argv, exception );
-
-    free( exception );
+    res = (long) libvlc_new(argc, (char**) argv, &exception );
+    CHECK_EXCEPTION ;
 
     return res;
 
index 5104f7d702d30fc70399ec1b0cac7b67fa42bd5b..70ec9e2f1edc48c32c1c165c1548304631b0103f 100644 (file)
@@ -24,9 +24,7 @@
  *****************************************************************************/
 
 #include <jni.h>
-
 #include <vlc/libvlc.h>
-
 /* JVLC internal imports, generated by gcjh */
 #include "../includes/Input.h"
 #include "utils.h"
@@ -117,7 +115,11 @@ JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Input__1isPlaying (JNIEnv *env
     vlc_bool_t res = 0;
     
     GET_INPUT_THREAD ;
-    
+  
+    if (input == NULL) {
+          return false;
+    }
+
     res = libvlc_media_instance_will_play( input, &exception );
     libvlc_media_instance_release(input);
     CHECK_EXCEPTION ;
@@ -132,6 +134,9 @@ JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Input__1hasVout (JNIEnv *env,
     
     GET_INPUT_THREAD ;
     
+    if (input == NULL) {
+          return false;
+    }
     res = libvlc_media_instance_has_vout( input, &exception );
     libvlc_media_instance_release(input);
     CHECK_EXCEPTION ;