Correctly pass 0 through JNI if ZIM file is corrupted

This commit is contained in:
mhutti1 2018-06-29 15:30:13 +02:00
parent 452e7f8883
commit ea8cd9f1a9
1 changed files with 6 additions and 6 deletions

View File

@ -21,6 +21,7 @@
#include <jni.h> #include <jni.h>
#include <zim/file.h> #include <zim/file.h>
#include <android/log.h>
#include "org_kiwix_kiwixlib_JNIKiwixReader.h" #include "org_kiwix_kiwixlib_JNIKiwixReader.h"
#include "common/base64.h" #include "common/base64.h"
@ -33,16 +34,15 @@ JNIEXPORT jlong JNICALL Java_org_kiwix_kiwixlib_JNIKiwixReader_getNativeReader(
{ {
std::string cPath = jni2c(filename, env); std::string cPath = jni2c(filename, env);
__android_log_print(ANDROID_LOG_INFO, "kiwix", "Attempting to create reader with: %s", cPath.c_str());
Lock l; Lock l;
kiwix::Reader* reader = nullptr;
try { try {
reader = new kiwix::Reader(cPath); kiwix::Reader* reader = new kiwix::Reader(cPath);
} catch (...) {
std::cerr << "Unable to load ZIM " << cPath << std::endl;
reader = NULL;
}
return reinterpret_cast<jlong>(new Handle<kiwix::Reader>(reader)); return reinterpret_cast<jlong>(new Handle<kiwix::Reader>(reader));
} catch (...) {
__android_log_print(ANDROID_LOG_WARN, "kiwix", "Error opening ZIM file");
return 0;
}
} }
JNIEXPORT void JNICALL JNIEXPORT void JNICALL