Use a #define J2K_MAX_POCS 32 to avoid hard-coded constant (#349)
authorEven Rouault <even.rouault@spatialys.com>
Tue, 19 Sep 2017 22:55:22 +0000 (00:55 +0200)
committerEven Rouault <even.rouault@spatialys.com>
Tue, 19 Sep 2017 22:55:22 +0000 (00:55 +0200)
src/lib/openjp2/j2k.c
src/lib/openjp2/j2k.h

index be2da8eca9eb2748fd101332549e75fd1180f0f1..36d4e94774fea7cedea9c207e3215473bdf1138d 100644 (file)
@@ -3502,11 +3502,10 @@ static OPJ_BOOL opj_j2k_read_poc(opj_j2k_t *p_j2k,
     l_old_poc_nb = l_tcp->POC ? l_tcp->numpocs + 1 : 0;
     l_current_poc_nb += l_old_poc_nb;
 
-    if (l_current_poc_nb >= 32) {
+    if (l_current_poc_nb >= J2K_MAX_POCS) {
         opj_event_msg(p_manager, EVT_ERROR, "Too many POCs %d\n", l_current_poc_nb);
         return OPJ_FALSE;
     }
-    assert(l_current_poc_nb < 32);
 
     /* now poc is in use.*/
     l_tcp->POC = 1;
index c9308f7dd8233ac9cb2c1d2d6ff6b0f914561033..d975419eb69b8f799e7c7da4b7b66e2688ff1c5f 100644 (file)
@@ -107,6 +107,8 @@ The functions in J2K.C have for goal to read/write the several parts of the code
 #endif /* USE_JPSEC */
 /* <<UniPG */
 
+#define J2K_MAX_POCS    32      /**< Maximum number of POCs */
+
 /* ----------------------------------------------------------------------- */
 
 /**
@@ -251,7 +253,7 @@ typedef struct opj_tcp {
     /** number of progression order changes */
     OPJ_UINT32 numpocs;
     /** progression order changes */
-    opj_poc_t pocs[32];
+    opj_poc_t pocs[J2K_MAX_POCS];
 
     /** number of ppt markers (reserved size) */
     OPJ_UINT32 ppt_markers_count;