diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2016-08-30 10:01:02 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2016-09-08 18:53:00 +0800 |
commit | b2048e4ee4a74fde76232ae34a446351c5fcd01a (patch) | |
tree | 777dfdd4d1a6e734c9988a1f2ef35974c3266895 /platform | |
parent | f690e82b36ebc6248da75fd77c957cb8d04d8b7c (diff) | |
download | mupdf-b2048e4ee4a74fde76232ae34a446351c5fcd01a.tar.xz |
JNI: Throw OutOfBoundsException for out of range values.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/java/mupdf_native.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index 35168696..7b0dd7c5 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -2791,21 +2791,9 @@ FUN(Pixmap_getSample)(JNIEnv *env, jobject self, jint x, jint y, jint k) if (!ctx) return 0; - if (x < 0 || x >= pixmap->w) - { - jni_throw(env, FZ_ERROR_GENERIC, "X out of range"); - return 0; - } - if (y < 0 || y >= pixmap->h) - { - jni_throw(env, FZ_ERROR_GENERIC, "Y out of range"); - return 0; - } - if (k < 0 || k >= pixmap->n) - { - jni_throw(env, FZ_ERROR_GENERIC, "K out of range"); - return 0; - } + if (x < 0 || x >= pixmap->w) { jni_throw_oob(env, "X out of range"); return 0; } + if (y < 0 || y >= pixmap->h) { jni_throw_oob(env, "Y out of range"); return 0; } + if (k < 0 || k >= pixmap->n) { jni_throw_oob(env, "K out of range"); return 0; } return pixmap->samples[(x + y * pixmap->w) * pixmap->n + k]; } |