opj_j2k_set_threads(): add sanity check to error out if called after opj_read_header()
authorEven Rouault <even.rouault@spatialys.com>
Wed, 11 Oct 2017 23:16:23 +0000 (01:16 +0200)
committerEven Rouault <even.rouault@spatialys.com>
Wed, 11 Oct 2017 23:16:23 +0000 (01:16 +0200)
src/lib/openjp2/j2k.c

index ad6e1b86fe34e6c7795a61c4775d45953bc57eec..6318719c04adab64bfed0371c84b4ab773653171 100644 (file)
@@ -6419,7 +6419,9 @@ void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters)
 
 OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads)
 {
-    if (opj_has_thread_support()) {
+    /* Currently we pass the thread-pool to the tcd, so we cannot re-set it */
+    /* afterwards */
+    if (opj_has_thread_support() && j2k->m_tcd == NULL) {
         opj_thread_pool_destroy(j2k->m_tp);
         j2k->m_tp = NULL;
         if (num_threads <= (OPJ_UINT32)INT_MAX) {