Buggy code:
static void sep_upsample ( JPEGDecoder . jpeg_decompress_struct cinfo , byte [ ] [ ] [ ] input_buf , int [ ] input_buf_offset , int [ ] in_row_group_ctr , int in_row_groups_avail , byte [ ] [ ] output_buf , int [ ] out_row_ctr , int out_rows_avail ) { } static void noop_upsample ( JPEGDecoder . jpeg_decompress_struct cinfo , JPEGDecoder . jpeg_component_info compptr , byte [ ] [ ] input_data , int input_data_offset , byte [ ] [ ] [ ] output_data_ptr , int [ ] output_data_offset , int output_data_index ) { } static void fullsize_upsample ( JPEGDecoder . jpeg_decompress_struct cinfo , JPEGDecoder . jpeg_component_info compptr , byte [ ] [ ] input_data , int input_data_offset , byte [ ] [ ] [ ] output_data_ptr , int [ ] output_data_offset , int output_data_index ) { } static void h2v1_upsample ( JPEGDecoder . jpeg_decompress_struct cinfo , JPEGDecoder . jpeg_component_info compptr , byte [ ] [ ] input_data , int input_data_offset , byte [ ] [ ] [ ] output_data_ptr , int [ ] output_data_offset , int output_data_index ) { } static void h2v2_upsample ( JPEGDecoder . jpeg_decompress_struct cinfo , JPEGDecoder . jpeg_component_info compptr , byte [ ] [ ] input_data , int input_data_offset , byte [ ] [ ] [ ] output_data_ptr , int [ ] output_data_offset , int output_data_index ) { } static void h2v1_fancy_upsample ( JPEGDecoder . jpeg_decompress_struct cinfo , JPEGDecoder . jpeg_component_info compptr , byte [ ] [ ] input_data , int input_data_offset , byte [ ] [ ] [ ] output_data_ptr , int [ ] output_data_offset , int output_data_index ) { } static void h2v2_fancy_upsample ( JPEGDecoder . jpeg_decompress_struct cinfo , JPEGDecoder . jpeg_component_info compptr , byte [ ] [ ] input_data , int input_data_offset , byte [ ] [ ] [ ] output_data_ptr , int [ ] output_data_offset , int output_data_index ) { } static void int_upsample ( JPEGDecoder . jpeg_decompress_struct cinfo , JPEGDecoder . jpeg_component_info compptr , byte [ ] [ ] input_data , int input_data_offset , byte [ ] [ ] [ ] output_data_ptr , int [ ] output_data_offset , int output_data_index ) { } static void null_convert ( JPEGDecoder . jpeg_decompress_struct cinfo , byte [ ] [ ] [ ] input_buf , int [ ] input_buf_offset , int input_row , byte [ ] [ ] output_buf , int output_buf_offset , int num_rows ) { } static void grayscale_convert ( JPEGDecoder . jpeg_decompress_struct cinfo , byte [ ] [ ] [ ] input_buf , int [ ] input_buf_offset , int input_row , byte [ ] [ ] output_buf , int output_buf_offset , int num_rows ) { } static void gray_rgb_convert ( JPEGDecoder . jpeg_decompress_struct cinfo , byte [ ] [ ] [ ] input_buf , int [ ] input_buf_offset , int input_row , byte [ ] [ ] output_buf , int output_buf_offset , int num_rows ) { } static void ycc_rgb_convert ( JPEGDecoder . jpeg_decompress_struct cinfo , byte [ ] [ ] [ ] input_buf , int [ ] input_buf_offset , int input_row , byte [ ] [ ] output_buf , int output_buf_offset , int num_rows ) { } static boolean process_APPn ( int n , JPEGDecoder . jpeg_decompress_struct cinfo ) { } static boolean process_COM ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static void skip_input_data ( JPEGDecoder . jpeg_decompress_struct cinfo , int num_bytes ) { } static boolean skip_variable ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static boolean get_interesting_appn ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static void examine_app0 ( JPEGDecoder . jpeg_decompress_struct cinfo , byte [ ] data , int datalen , int remaining ) { } static void examine_app14 ( JPEGDecoder . jpeg_decompress_struct cinfo , byte [ ] data , int datalen , int remaining ) { } static boolean get_soi ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static void jinit_input_controller ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static void reset_marker_reader ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static void reset_input_controller ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static void finish_output_pass ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static void jpeg_destroy ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static void jpeg_destroy_decompress ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static boolean jpeg_input_complete ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static boolean jpeg_start_output ( JPEGDecoder . jpeg_decompress_struct cinfo , int scan_number ) { } static boolean jpeg_finish_output ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static boolean jpeg_finish_decompress ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static int jpeg_read_header ( JPEGDecoder . jpeg_decompress_struct cinfo , boolean require_image ) { } static int dummy_consume_data ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static int consume_data ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static int consume_input ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static boolean fill_input_buffer ( JPEGDecoder . jpeg_decompress_struct cinfo ) { try { InputStream inputStream = cinfo . inputStream ; <START_BUG> int nbytes = inputStream . read ( cinfo . buffer , 0 , Math . min ( cinfo . buffer . length , inputStream . available ( ) ) ) ; <END_BUG> if ( nbytes <= 0 ) { if ( cinfo . start_of_file ) JPEGDecoder . error ( ) ; cinfo . buffer [ 0 ] = ( ( byte ) ( 255 ) ) ; cinfo . buffer [ 1 ] = ( ( byte ) ( JPEGDecoder . M_EOI ) ) ; nbytes = 2 ; } cinfo . bytes_in_buffer = nbytes ; cinfo . bytes_offset = 0 ; cinfo . start_of_file = false ; } catch ( IOException e ) { JPEGDecoder . error ( ERROR_IO ) ; return false ; } return true ; } static boolean first_marker ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static boolean next_marker ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static int read_markers ( JPEGDecoder . jpeg_decompress_struct cinfo ) { } static long jdiv_round_up ( long a , long b ) { }

Fix:
int nbytes = inputStream . read ( cinfo . buffer ) ;