diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-04-18 03:46:54 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2017-04-20 19:47:03 +0800 |
commit | 1f1c5a6a813229c52ed2af086bbf462b1b986338 (patch) | |
tree | 63967f7cfab764221128e587d89b2c9ed9937bd6 /platform | |
parent | 1c4483f5f01377495bda09438364e3e2ea13af98 (diff) | |
download | mupdf-1f1c5a6a813229c52ed2af086bbf462b1b986338.tar.xz |
jni: to_Annotation() may fz_throw(), make it safe.
Previously to_Annotation() would fz_throw() upon errors,
but the code calling it couldn't handle that. Create
to_Annotation_safe() that does not throw and remove the
now unused to_Annotation().
Diffstat (limited to 'platform')
-rw-r--r-- | platform/java/mupdf_native.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index d8d713e3..9110dbd5 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -1005,26 +1005,6 @@ FUN(Context_gprfSupportedNative)(JNIEnv * env, jclass class) /* Conversion functions: C to Java. These all throw fitz exceptions. */ -static inline jobject to_Annotation(fz_context *ctx, JNIEnv *env, fz_annot *annot) -{ - jobject jannot; - pdf_annot *pannot; - - if (!ctx || !annot) return NULL; - - fz_keep_annot(ctx, annot); - - pannot = pdf_annot_from_fz_annot(ctx, annot); - if (pannot) - jannot = (*env)->NewObject(env, cls_PDFAnnotation, mid_PDFAnnotation_init, jlong_cast(annot)); - else - jannot = (*env)->NewObject(env, cls_Annotation, mid_Annotation_init, jlong_cast(annot)); - if (!jannot) - fz_throw_java(ctx, env); - - return jannot; -} - static inline jobject to_ColorSpace(fz_context *ctx, JNIEnv *env, fz_colorspace *cs) { jobject jcs; @@ -1154,6 +1134,24 @@ static inline jfloatArray to_jfloatArray(fz_context *ctx, JNIEnv *env, const flo /* Conversion functions: C to Java. None of these throw fitz exceptions. */ +static inline jobject to_Annotation_safe(fz_context *ctx, JNIEnv *env, fz_annot *annot) +{ + jobject jannot; + pdf_annot *pannot; + + if (!ctx || !annot) return NULL; + + fz_keep_annot(ctx, annot); + + pannot = pdf_annot_from_fz_annot(ctx, annot); + if (pannot) + jannot = (*env)->NewObject(env, cls_PDFAnnotation, mid_PDFAnnotation_init, jlong_cast(annot)); + else + jannot = (*env)->NewObject(env, cls_Annotation, mid_Annotation_init, jlong_cast(annot)); + + return jannot; +} + static inline jobject to_ColorSpace_safe(fz_context *ctx, JNIEnv *env, fz_colorspace *cs) { jobject jcs; @@ -4874,7 +4872,7 @@ FUN(Page_getAnnotations)(JNIEnv *env, jobject self) annot = annots; for (i = 0; annot && i < annot_count; i++) { - jobject jannot = to_Annotation(ctx, env, annot); + jobject jannot = to_Annotation_safe(ctx, env, annot); if (!jannot) return NULL; (*env)->SetObjectArrayElement(env, jannots, i, jannot); |