1diff --git a/third_party/libopenjpeg20/j2k.c b/third_party/libopenjpeg20/j2k.c
2index 849d0b4..b20f219 100644
3--- a/third_party/libopenjpeg20/j2k.c
4+++ b/third_party/libopenjpeg20/j2k.c
5@@ -5341,6 +5341,7 @@ static OPJ_BOOL opj_j2k_read_mcc (     opj_j2k_t *p_j2k,
6         OPJ_UINT32 l_nb_collections;
7         OPJ_UINT32 l_nb_comps;
8         OPJ_UINT32 l_nb_bytes_by_comp;
9+        OPJ_BOOL new_mcc = OPJ_FALSE;
10
11         /* preconditions */
12         assert(p_header_data != 00);
13@@ -5402,6 +5403,7 @@ static OPJ_BOOL opj_j2k_read_mcc (     opj_j2k_t *p_j2k,
14                         memset(l_mcc_record,0,(l_tcp->m_nb_max_mcc_records-l_tcp->m_nb_mcc_records) * sizeof(opj_simple_mcc_decorrelation_data_t));
15                 }
16                 l_mcc_record = l_tcp->m_mcc_records + l_tcp->m_nb_mcc_records;
17+                new_mcc = OPJ_TRUE;
18         }
19         l_mcc_record->m_index = l_indix;
20
21@@ -5537,7 +5539,9 @@ static OPJ_BOOL opj_j2k_read_mcc (     opj_j2k_t *p_j2k,
22                 return OPJ_FALSE;
23         }
24
25-        ++l_tcp->m_nb_mcc_records;
26+        if (new_mcc) {
27+                ++l_tcp->m_nb_mcc_records;
28+        }
29
30         return OPJ_TRUE;
31 }
32