| diff --git a/third_party/libopenjpeg/j2k.c b/third_party/libopenjpeg/j2k.c |
| index 1932fe20c..d24564cc2 100644 |
| --- a/third_party/libopenjpeg/j2k.c |
| +++ b/third_party/libopenjpeg/j2k.c |
| @@ -5749,6 +5749,7 @@ static OPJ_BOOL opj_j2k_read_mct(opj_j2k_t *p_j2k, |
| OPJ_UINT32 l_tmp; |
| OPJ_UINT32 l_indix; |
| opj_mct_data_t * l_mct_data; |
| + OPJ_BOOL new_mct = OPJ_FALSE; |
| |
| /* preconditions */ |
| assert(p_header_data != 00); |
| @@ -5836,7 +5837,7 @@ static OPJ_BOOL opj_j2k_read_mct(opj_j2k_t *p_j2k, |
| } |
| |
| l_mct_data = l_tcp->m_mct_records + l_tcp->m_nb_mct_records; |
| - ++l_tcp->m_nb_mct_records; |
| + new_mct = OPJ_TRUE; |
| } |
| |
| if (l_mct_data->m_data) { |
| @@ -5868,6 +5869,9 @@ static OPJ_BOOL opj_j2k_read_mct(opj_j2k_t *p_j2k, |
| |
| l_mct_data->m_data_size = p_header_size; |
| |
| + if (new_mct) { |
| + ++l_tcp->m_nb_mct_records; |
| + } |
| return OPJ_TRUE; |
| } |
| |