From ea8cd9f1a9836fc0b425c0dcbbd729edc9d967fb Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Fri, 29 Jun 2018 15:30:13 +0200 Subject: [PATCH] Correctly pass 0 through JNI if ZIM file is corrupted --- src/android/kiwixreader.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/android/kiwixreader.cpp b/src/android/kiwixreader.cpp index 769f25286..fac6c0096 100644 --- a/src/android/kiwixreader.cpp +++ b/src/android/kiwixreader.cpp @@ -21,6 +21,7 @@ #include #include +#include #include "org_kiwix_kiwixlib_JNIKiwixReader.h" #include "common/base64.h" @@ -33,16 +34,15 @@ JNIEXPORT jlong JNICALL Java_org_kiwix_kiwixlib_JNIKiwixReader_getNativeReader( { std::string cPath = jni2c(filename, env); + __android_log_print(ANDROID_LOG_INFO, "kiwix", "Attempting to create reader with: %s", cPath.c_str()); Lock l; - kiwix::Reader* reader = nullptr; try { - reader = new kiwix::Reader(cPath); + kiwix::Reader* reader = new kiwix::Reader(cPath); + return reinterpret_cast(new Handle(reader)); } catch (...) { - std::cerr << "Unable to load ZIM " << cPath << std::endl; - reader = NULL; + __android_log_print(ANDROID_LOG_WARN, "kiwix", "Error opening ZIM file"); + return 0; } - - return reinterpret_cast(new Handle(reader)); } JNIEXPORT void JNICALL