Merge pull request #975 from szukw000/changes-for-afl-tests
authorAntonin Descampe <antonin@descampe.net>
Tue, 8 Aug 2017 23:51:54 +0000 (16:51 -0700)
committerGitHub <noreply@github.com>
Tue, 8 Aug 2017 23:51:54 +0000 (16:51 -0700)
Catch images broken by AFL

1  2 
src/bin/common/color.c
src/lib/openjp2/j2k.c
src/lib/openjp2/jp2.c
src/lib/openjp2/openjpeg.h
src/lib/openjp2/tcd.h

Simple merge
index 3737655b2fbb19947d213c53966bb8b0af938dcd,8daf9be8c4848b283ecdc15628c652946a5c0437..5a169e1809edc97106888716e370e96b3ee5a3f9
@@@ -8735,21 -8739,17 +8769,22 @@@ OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t 
          opj_event_msg(p_manager, EVT_ERROR, "Failed to decode.\n");
          return OPJ_FALSE;
      }
+     p_j2k->m_tcd->enumcs = p_j2k->enumcs;
  
 -    if (! opj_tcd_update_tile_data(p_j2k->m_tcd, p_data, p_data_size)) {
 -        return OPJ_FALSE;
 -    }
 +    /* p_data can be set to NULL when the call will take care of using */
 +    /* itself the TCD data. This is typically the case for whole single */
 +    /* tile decoding optimization. */
 +    if (p_data != NULL) {
 +        if (! opj_tcd_update_tile_data(p_j2k->m_tcd, p_data, p_data_size)) {
 +            return OPJ_FALSE;
 +        }
  
 -    /* To avoid to destroy the tcp which can be useful when we try to decode a tile decoded before (cf j2k_random_tile_access)
 -     * we destroy just the data which will be re-read in read_tile_header*/
 -    /*opj_j2k_tcp_destroy(l_tcp);
 -    p_j2k->m_tcd->tcp = 0;*/
 -    opj_j2k_tcp_data_destroy(l_tcp);
 +        /* To avoid to destroy the tcp which can be useful when we try to decode a tile decoded before (cf j2k_random_tile_access)
 +        * we destroy just the data which will be re-read in read_tile_header*/
 +        /*opj_j2k_tcp_destroy(l_tcp);
 +        p_j2k->m_tcd->tcp = 0;*/
 +        opj_j2k_tcp_data_destroy(l_tcp);
 +    }
  
      p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
      p_j2k->m_specific_param.m_decoder.m_state &= (~(OPJ_UINT32)J2K_STATE_DATA);
Simple merge
Simple merge
Simple merge