mirror of https://github.com/kiwix/libkiwix.git
Correctly pass 0 through JNI if ZIM file is corrupted
This commit is contained in:
parent
452e7f8883
commit
ea8cd9f1a9
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue