--- old/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c 2016-09-06 19:15:24.995174000 +0530 +++ new/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c 2016-09-06 19:15:24.319174000 +0530 @@ -1,5 +1,5 @@ /* - * 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 @@ -1043,6 +1043,7 @@ 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; } @@ -1798,9 +1799,14 @@ 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; @@ -2010,6 +2016,7 @@ 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; @@ -2018,6 +2025,7 @@ 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; @@ -2041,15 +2049,24 @@ // 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 @@ -2137,8 +2154,13 @@ 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); + } } } @@ -3099,3 +3121,4 @@ imageio_dispose(info); } +