OpenJDK / jdk8u / jdk8u / jdk
changeset 11327:43325651ebb8
8139017: More stable image decoding
Reviewed-by: prr, serb, mschoene
author | vadim |
---|---|
date | Fri, 16 Oct 2015 14:12:35 +0300 |
parents | d4f2c6280868 |
children | 1a9ced185295 |
files | src/share/native/sun/awt/image/jpeg/jpegdecoder.c |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/native/sun/awt/image/jpeg/jpegdecoder.c Wed Oct 21 00:21:57 2015 -0700 +++ b/src/share/native/sun/awt/image/jpeg/jpegdecoder.c Fri Oct 16 14:12:35 2015 +0300 @@ -180,6 +180,7 @@ int *ip; unsigned char *bp; } outbuf; + size_t outbufSize; jobject hOutputBuffer; }; @@ -235,6 +236,7 @@ assert(src->outbuf.ip == 0); src->outbuf.ip = (int *)(*env)->GetPrimitiveArrayCritical (env, src->hOutputBuffer, 0); + src->outbufSize = (*env)->GetArrayLength(env, src->hOutputBuffer); if (src->outbuf.ip == 0) { RELEASE_ARRAYS(env, src); return 0; @@ -677,8 +679,8 @@ cinfo.output_scanline - 1); } else { if (hasalpha) { - ip = jsrc.outbuf.ip + cinfo.image_width; - bp = jsrc.outbuf.bp + cinfo.image_width * 4; + ip = jsrc.outbuf.ip + jsrc.outbufSize; + bp = jsrc.outbuf.bp + jsrc.outbufSize * 4; while (ip > jsrc.outbuf.ip) { pixel = (*--bp) << 24; pixel |= (*--bp); @@ -687,8 +689,8 @@ *--ip = pixel; } } else { - ip = jsrc.outbuf.ip + cinfo.image_width; - bp = jsrc.outbuf.bp + cinfo.image_width * 3; + ip = jsrc.outbuf.ip + jsrc.outbufSize; + bp = jsrc.outbuf.bp + jsrc.outbufSize * 3; while (ip > jsrc.outbuf.ip) { pixel = (*--bp); pixel |= (*--bp) << 8;