From 8222c54c6640381b4afb0c6197f808d5019b509d Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 27 May 2013 18:28:57 +0100 Subject: Fix a crash when saving a file in the android app. When saving, we'd close the document before we save it. As part of the leak fixing work, I'd freed the path as part of the closing process. Rework slightly to avoid this. --- android/jni/mupdf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'android/jni') diff --git a/android/jni/mupdf.c b/android/jni/mupdf.c index 514bdde4..b185f219 100644 --- a/android/jni/mupdf.c +++ b/android/jni/mupdf.c @@ -1595,6 +1595,8 @@ JNI_FN(MuPDFCore_deleteAnnotationInternal)(JNIEnv * env, jobject thiz, int annot } } +/* Close the document, at least enough to be able to save over it. This + * may be called again later, so must be idempotent. */ static void close_doc(globals *glo) { int i; @@ -1609,8 +1611,6 @@ static void close_doc(globals *glo) fz_close_document(glo->doc); glo->doc = NULL; - fz_free_context(glo->ctx); - glo->ctx = NULL; } JNIEXPORT void JNICALL @@ -1624,6 +1624,8 @@ JNI_FN(MuPDFCore_destroying)(JNIEnv * env, jobject thiz) fz_free(glo->ctx, glo->current_path); glo->current_path = NULL; close_doc(glo); + fz_free_context(glo->ctx); + glo->ctx = NULL; free(glo); #ifdef MEMENTO LOGI("Destroying dump start"); -- cgit v1.2.3