Blame SOURCES/openjpeg2_coverity.patch

7726c0
diff --git a/src/bin/jp2/convertpng.c b/src/bin/jp2/convertpng.c
f8c58c
index 00f596e..af3f91e 100644
7726c0
--- a/src/bin/jp2/convertpng.c
7726c0
+++ b/src/bin/jp2/convertpng.c
7726c0
@@ -75,10 +75,10 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
7726c0
     png_uint_32  width, height = 0U;
7726c0
     int color_type;
7726c0
     FILE *reader = NULL;
7726c0
-    OPJ_BYTE** rows = NULL;
7726c0
-    OPJ_INT32* row32s = NULL;
7726c0
+    OPJ_BYTE** volatile rows = NULL;
7726c0
+    OPJ_INT32* volatile row32s = NULL;
7726c0
     /* j2k: */
7726c0
-    opj_image_t *image = NULL;
7726c0
+    opj_image_t* volatile image = NULL;
7726c0
     opj_image_cmptparm_t cmptparm[4];
7726c0
     OPJ_UINT32 nr_comp;
7726c0
     OPJ_BYTE sigbuf[8];
7726c0
diff --git a/src/bin/jp2/converttif.c b/src/bin/jp2/converttif.c
f8c58c
index 9d1037a..8d5002a 100644
7726c0
--- a/src/bin/jp2/converttif.c
7726c0
+++ b/src/bin/jp2/converttif.c
f8c58c
@@ -720,7 +720,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
7726c0
         TIFFClose(tif);
7726c0
         return 1;
7726c0
     }
7726c0
-    rowStride = (int64_t)((width * numcomps * bps + 7U) / 8U);
7726c0
+    rowStride = ((int64_t)width * numcomps * bps + 7U) / 8U;
7726c0
     if (rowStride != strip_size) {
7726c0
         fprintf(stderr, "Invalid TIFF strip size\n");
7726c0
         TIFFClose(tif);
f8c58c
@@ -1283,8 +1283,6 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
7726c0
     TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &tiSpp);
7726c0
     TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &tiPhoto);
7726c0
     TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &tiPC);
7726c0
-    w = (int)tiWidth;
7726c0
-    h = (int)tiHeight;
7726c0
 
7726c0
     if (tiSpp == 0 || tiSpp > 4) { /* should be 1 ... 4 */
7726c0
         fprintf(stderr, "tiftoimage: Bad value for samples per pixel == %d.\n"
f8c58c
@@ -1451,7 +1449,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
7726c0
         return NULL;
7726c0
     }
7726c0
 
7726c0
-    rowStride = (int64_t)((tiWidth * tiSpp * tiBps + 7U) / 8U);
7726c0
+    rowStride = ((int64_t)tiWidth * tiSpp * tiBps + 7U) / 8U;
7726c0
     buffer32s = (OPJ_INT32 *)malloc(sizeof(OPJ_INT32) * tiWidth * tiSpp);
7726c0
     if (buffer32s == NULL) {
7726c0
         _TIFFfree(buf);
f8c58c
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
f8c58c
index 8e343ab..c13d229 100644
f8c58c
--- a/src/lib/openjp2/j2k.c
f8c58c
+++ b/src/lib/openjp2/j2k.c
f8c58c
@@ -7075,7 +7075,7 @@ static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
f8c58c
     /* Validate sublevel */
f8c58c
     assert(sizeof(tabMaxSubLevelFromMainLevel) ==
f8c58c
            (OPJ_IMF_MAINLEVEL_MAX + 1) * sizeof(tabMaxSubLevelFromMainLevel[0]));
f8c58c
-    if (sublevel > tabMaxSubLevelFromMainLevel[mainlevel]) {
f8c58c
+    if (mainlevel <= OPJ_IMF_MAINLEVEL_MAX && sublevel > tabMaxSubLevelFromMainLevel[mainlevel]) {
f8c58c
         opj_event_msg(p_manager, EVT_WARNING,
f8c58c
                       "IMF profile require sublevel <= %d for mainlevel = %d.\n"
f8c58c
                       "-> %d is thus not compliant\n"
f8c58c
diff --git a/src/lib/openjp2/t2.c b/src/lib/openjp2/t2.c
f8c58c
index 1481e16..d46bfb4 100644
f8c58c
--- a/src/lib/openjp2/t2.c
f8c58c
+++ b/src/lib/openjp2/t2.c
f8c58c
@@ -821,6 +821,7 @@ static OPJ_BOOL opj_t2_encode_packet(OPJ_UINT32 tileno,
f8c58c
             opj_event_msg(p_manager, EVT_ERROR,
f8c58c
                           "opj_t2_encode_packet(): accessing precno=%u >= %u\n",
f8c58c
                           precno, res->pw * res->ph);
f8c58c
+            opj_bio_destroy(bio);
f8c58c
             return OPJ_FALSE;
f8c58c
         }
f8c58c