Commit 774bcd52 authored by flx42's avatar flx42
Browse files

LibVLC: handle failures when getting the cache path

parent 606a53a4
......@@ -262,8 +262,11 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
methodId = (*env)->GetMethodID(env, cls, "getCachePath", "()Ljava/lang/String;");
jstring cachePath = (*env)->CallObjectMethod(env, thiz, methodId);
const char *cache_path = (*env)->GetStringUTFChars(env, cachePath, 0);
setenv("DVDCSS_CACHE", cache_path, 1);
if (cachePath) {
const char *cache_path = (*env)->GetStringUTFChars(env, cachePath, 0);
setenv("DVDCSS_CACHE", cache_path, 1);
(*env)->ReleaseStringUTFChars(env, cachePath, cache_path);
}
/* Don't add any invalid options, otherwise it causes LibVLC to crash */
const char *argv[] = {
......@@ -297,7 +300,6 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
(*env)->ReleaseStringUTFChars(env, chroma, chromastr);
(*env)->ReleaseStringUTFChars(env, subsencoding, subsencodingstr);
(*env)->ReleaseStringUTFChars(env, cachePath, cache_path);
if (!instance)
{
......
......@@ -20,6 +20,7 @@
package org.videolan.libvlc;
import java.io.File;
import java.util.ArrayList;
import java.util.Map;
......@@ -378,7 +379,8 @@ public class LibVLC {
throw new LibVlcException();
}
mCachePath = context.getCacheDir().getAbsolutePath();
File cacheDir = context.getCacheDir();
mCachePath = (cacheDir != null) ? cacheDir.getAbsolutePath() : null;
nativeInit();
mMediaList = mPrimaryList = new MediaList(this);
setEventHandler(EventHandler.getInstance());
......
Supports Markdown
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