Skip to content

Commit

Permalink
Amend fix of PR 1530 regarding m_sot_length check
Browse files Browse the repository at this point in the history
The fix of 2c0823c (#1530) broke
decoding of some JPEG2000 files where Isot==0, Psot==0, TPsot==0 and
TNsot==0 like the following ones from the GDAL autotest suite:
autotest/gdrivers/data/jpeg2000/stefan_full_rgba_alpha_1bit.jp2
autotest/gdrivers/data/jpeg2000/3_13bit_and_1bit.jp2
  • Loading branch information
rouault committed Nov 13, 2024
1 parent 4ec0aca commit c34e441
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -9792,7 +9792,8 @@ OPJ_BOOL opj_j2k_read_tile_header(opj_j2k_t * p_j2k,
}

/* Why this condition? FIXME */
if (p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_TPH) {
if ((p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_TPH) &&
p_j2k->m_specific_param.m_decoder.m_sot_length != 0) {
if (p_j2k->m_specific_param.m_decoder.m_sot_length < l_marker_size + 2) {
opj_event_msg(p_manager, EVT_ERROR,
"Sot length is less than marker size + marker ID\n");
Expand Down

0 comments on commit c34e441

Please sign in to comment.