< prev index next >

src/java.desktop/share/native/libjavajpeg/imageioJPEG.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2000, 2014, 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 --- 1,7 ---- /* ! * 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
*** 567,583 **** --- 567,596 ---- CHECK_NULL(string); theObject = data->imageIOobj; if (cinfo->is_decompressor) { + struct jpeg_source_mgr *src = ((j_decompress_ptr)cinfo)->src; + RELEASE_ARRAYS(env, data, src->next_input_byte); (*env)->CallVoidMethod(env, theObject, JPEGImageReader_warningWithMessageID, string); + if ((*env)->ExceptionOccurred(env) + || !GET_ARRAYS(env, data, &(src->next_input_byte))) { + cinfo->err->error_exit(cinfo); + } } else { + struct jpeg_destination_mgr *dest = ((j_compress_ptr)cinfo)->dest; + RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte)); (*env)->CallVoidMethod(env, theObject, JPEGImageWriter_warningWithMessageID, string); + if ((*env)->ExceptionOccurred(env) + || !GET_ARRAYS(env, data, + (const JOCTET **)(&dest->next_output_byte))) { + cinfo->err->error_exit(cinfo); + } } } /* End of verbatim copy from jpegdecoder.c */
*** 1041,1050 **** --- 1054,1064 ---- 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,1808 **** --- 1810,1827 ---- 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,2025 **** --- 2027,2046 ---- 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,2057 **** 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) { (*env)->CallVoidMethod(env, this, JPEGImageReader_passStartedID, cinfo->input_scan_number-1); } } else if (wantUpdates) { (*env)->CallVoidMethod(env, this, JPEGImageReader_passStartedID, 0); ! } // Skip until the first interesting line while ((data->abortFlag == JNI_FALSE) && ((jint)cinfo->output_scanline < sourceYStart)) { --- 2060,2087 ---- 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,2146 **** --- 2165,2181 ---- } } 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
*** 2835,2845 **** jerr = (sun_jpeg_error_ptr) cinfo->err; if (setjmp(jerr->setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error while writing. */ - RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte)); if (!(*env)->ExceptionOccurred(env)) { char buffer[JMSG_LENGTH_MAX]; (*cinfo->err->format_message) ((j_common_ptr) cinfo, buffer); JNU_ThrowByName(env, "javax/imageio/IIOException", buffer); --- 2870,2879 ----
< prev index next >