summaryrefslogtreecommitdiff
path: root/android/jni
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-05-27 18:28:57 +0100
committerRobin Watts <robin.watts@artifex.com>2013-05-27 19:58:31 +0100
commit8222c54c6640381b4afb0c6197f808d5019b509d (patch)
treec5e2c875bc7f571eda90467e3fcc97afe8311efb /android/jni
parent95cf5b2cb3aa20b3203286e14b67064774270a4b (diff)
downloadmupdf-8222c54c6640381b4afb0c6197f808d5019b509d.tar.xz
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.
Diffstat (limited to 'android/jni')
-rw-r--r--android/jni/mupdf.c6
1 files changed, 4 insertions, 2 deletions
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");