< prev index next >
src/java.desktop/share/native/libjavajpeg/imageioJPEG.c
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -1041,10 +1041,11 @@
buflen = sb->bufferLength - offset;
if (buflen <= 0) {
if (!GET_ARRAYS(env, data, &(src->next_input_byte))) {
cinfo->err->error_exit((j_common_ptr) cinfo);
}
+ RELEASE_ARRAYS(env, data, src->next_input_byte);
return;
}
ret = (*env)->CallIntMethod(env, input,
JPEGImageReader_readInputDataID,
@@ -1796,13 +1797,18 @@
cinfo->image_height,
cinfo->jpeg_color_space,
cinfo->out_color_space,
cinfo->num_components,
profileData);
+ if ((*env)->ExceptionOccurred(env)
+ || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+ cinfo->err->error_exit((j_common_ptr) cinfo);
+ }
if (reset) {
jpeg_abort_decompress(cinfo);
}
+ RELEASE_ARRAYS(env, data, src->next_input_byte);
}
return retval;
}
@@ -2008,18 +2014,20 @@
data->streamBuf.suspendable = FALSE;
jpeg_start_decompress(cinfo);
if (numBands != cinfo->output_components) {
+ RELEASE_ARRAYS(env, data, src->next_input_byte);
JNU_ThrowByName(env, "javax/imageio/IIOException",
"Invalid argument to native readImage");
return data->abortFlag;
}
if (cinfo->output_components <= 0 ||
cinfo->image_width > (0xffffffffu / (unsigned int)cinfo->output_components))
{
+ RELEASE_ARRAYS(env, data, src->next_input_byte);
JNU_ThrowByName(env, "javax/imageio/IIOException",
"Invalid number of output components");
return data->abortFlag;
}
@@ -2039,19 +2047,28 @@
if (progressive) {
// initialize the next pass. Note that this skips up to
// the first interesting pass.
jpeg_start_output(cinfo, cinfo->input_scan_number);
if (wantUpdates) {
+ RELEASE_ARRAYS(env, data, src->next_input_byte);
(*env)->CallVoidMethod(env, this,
JPEGImageReader_passStartedID,
cinfo->input_scan_number-1);
+ if ((*env)->ExceptionOccurred(env)
+ || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+ cinfo->err->error_exit((j_common_ptr) cinfo);
+ }
}
} else if (wantUpdates) {
+ RELEASE_ARRAYS(env, data, src->next_input_byte);
(*env)->CallVoidMethod(env, this,
JPEGImageReader_passStartedID,
0);
-
+ if ((*env)->ExceptionOccurred(env)
+ || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+ cinfo->err->error_exit((j_common_ptr) cinfo);
+ }
}
// Skip until the first interesting line
while ((data->abortFlag == JNI_FALSE)
&& ((jint)cinfo->output_scanline < sourceYStart)) {
@@ -2135,12 +2152,17 @@
}
} else {
done = TRUE;
}
if (wantUpdates) {
+ RELEASE_ARRAYS(env, data, src->next_input_byte);
(*env)->CallVoidMethod(env, this,
JPEGImageReader_passCompleteID);
+ if ((*env)->ExceptionOccurred(env)
+ || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+ cinfo->err->error_exit((j_common_ptr) cinfo);
+ }
}
}
/*
* We are done, but we might not have read all the lines, or all
@@ -3097,5 +3119,6 @@
imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
j_common_ptr info = destroyImageioData(env, data);
imageio_dispose(info);
}
+
< prev index next >