From 005e75bdc390fb81307d325ee90086a26e95f954 Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Wed, 26 Feb 2014 11:16:32 +0000 Subject: [PATCH] [trunk] Import (ugly) patch from sumatrapdf team. This feels like a hack rather than a solution. Fixes issue 226 --- src/lib/openjp2/j2k.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index 5bbad1b9..aa4f1d1d 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -7367,6 +7367,12 @@ OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k, /* Read 2 bytes from the buffer as the marker size */ opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_marker_size,2); + /* cf. https://code.google.com/p/openjpeg/issues/detail?id=226 */ + if (l_current_marker == 0x8080 && opj_stream_get_number_byte_left(p_stream) == 0) { + p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC; + break; + } + /* Why this condition? FIXME */ if (p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_TPH){ p_j2k->m_specific_param.m_decoder.m_sot_length -= (l_marker_size + 2);