From 71a4291781e7db6f0ebdf18acb74ef290110c185 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 8 Nov 2017 15:28:47 +0000 Subject: Bug 698616: Fix use after free in Page_textAsHtml --- platform/java/mupdf_native.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'platform/java') diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index 171a2e8d..4a2274f7 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -5069,9 +5069,11 @@ FUN(Page_textAsHtml)(JNIEnv *env, jobject self) len = fz_buffer_storage(ctx, buf, &data); arr = (*env)->NewByteArray(env, (jsize)len); + if (arr) + { + (*env)->SetByteArrayRegion(env, arr, 0, (jsize)len, (jbyte *)data); + } fz_drop_buffer(ctx, buf); - if (!arr) return NULL; - (*env)->SetByteArrayRegion(env, arr, 0, (jsize)len, (jbyte *)data); if ((*env)->ExceptionCheck(env)) return NULL; return arr; -- cgit v1.2.3