--- a/jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c Tue Oct 06 09:20:12 2015 +0200
+++ b/jdk/src/java.desktop/share/native/libjavajpeg/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;