about summary refs log tree commit diff
path: root/converter/other/jpeg2000/libjasper
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/jpeg2000/libjasper')
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_image.c4
-rw-r--r--converter/other/jpeg2000/libjasper/jp2/jp2_dec.c3
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_dec.c23
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_math.c4
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_math.h7
5 files changed, 35 insertions, 6 deletions
diff --git a/converter/other/jpeg2000/libjasper/base/jas_image.c b/converter/other/jpeg2000/libjasper/base/jas_image.c
index 903b45c6..5c2822be 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_image.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_image.c
@@ -885,6 +885,10 @@ int jas_image_depalettize(jas_image_t *image, int cmptno, int numlutents,
 	cmptparms.prec = JAS_IMAGE_CDT_GETPREC(dtype);
 	cmptparms.sgnd = JAS_IMAGE_CDT_GETSGND(dtype);
 
+	if (numlutents < 1) {
+		return -1;
+	}
+
 	if (jas_image_addcmpt(image, newcmptno, &cmptparms)) {
 		return -1;
 	}
diff --git a/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c b/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c
index a9463a57..4036f0f2 100644
--- a/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c
+++ b/converter/other/jpeg2000/libjasper/jp2/jp2_dec.c
@@ -563,6 +563,9 @@ jp2_decode(jas_stream_t *in, char *optstr) {
                                   channo + 1));
                 }
 #endif
+            } else {
+                jas_eprintf("error: invalid MTYP in CMAP box\n");
+                goto error;
             }
         }
     }
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c
index cada97f8..4d4dfc50 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c
@@ -597,7 +597,9 @@ static int jpc_dec_process_sod(jpc_dec_t *dec, jpc_ms_t *ms)
         if (!jpc_dec_cp_isvalid(tile->cp)) {
             return -1;
         }
-        jpc_dec_cp_prepare(tile->cp);
+        if (jpc_dec_cp_prepare(tile->cp)) {
+            return -1;
+        }
         if (jpc_dec_tileinit(dec, tile)) {
             return -1;
         }
@@ -1249,6 +1251,15 @@ static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms)
         return -1;
     }
 
+    for (tileno = 0, tile = dec->tiles;
+         tileno < dec->numtiles;
+         ++tileno, ++tile) {
+        /* initialize all tiles with JPC_TILE_DONE so jpc_dec_destroy() knows
+           which ones need a jpc_dec_tilefini() call; they are not actually
+           "done", of course */
+        tile->state = JPC_TILE_DONE;
+    }
+
     for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; ++tileno,
       ++tile) {
         htileno = tileno % dec->numhtiles;
@@ -1929,6 +1940,16 @@ static void jpc_dec_destroy(jpc_dec_t *dec)
     }
 
     if (dec->tiles) {
+        int tileno;
+        jpc_dec_tile_t *tile;
+
+        for (tileno = 0, tile = dec->tiles;
+             tileno < dec->numtiles;
+             ++tileno, ++tile) {
+            if (tile->state != JPC_TILE_DONE) {
+                jpc_dec_tilefini(dec, tile);
+            }
+        }
         jas_free(dec->tiles);
     }
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_math.c b/converter/other/jpeg2000/libjasper/jpc/jpc_math.c
index 72e3ac37..01e3611e 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_math.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_math.c
@@ -12,7 +12,7 @@
 /* Calculate the integer quantity floor(log2(x)), where x is a positive
   integer. */
 int
-jpc_floorlog2(int const arg) {
+jpc_floorlog2(int_fast32_t const arg) {
 
 	int y;
     int x;
@@ -46,7 +46,7 @@ jpc_firstone(n)    :-1 0  1  1  2  2  2  2  3  3  3  3  3  3  3  3  4  4  4  4
 
 
 int
-jpc_firstone(int const arg) {
+jpc_firstone(int_fast32_t const arg) {
 /*---------------------------------------------------------------------------- 
   Calculate the bit position of the first leading one in a nonnegative
   integer.
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_math.h b/converter/other/jpeg2000/libjasper/jpc/jpc_math.h
index 77df0c62..cd24c6a6 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_math.h
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_math.h
@@ -115,7 +115,8 @@
 * Includes
 \******************************************************************************/
 
-#include	<assert.h>
+#include <assert.h>
+#include <stdint.h>
 
 /******************************************************************************\
 * Macros
@@ -146,10 +147,10 @@
 
 /* Calculate the bit position of the first leading one in a nonnegative
   integer. */
-int jpc_firstone(int x);
+int jpc_firstone(int_fast32_t x);
 
 /* Calculate the integer quantity floor(log2(x)), where x is a positive
   integer. */
-int jpc_floorlog2(int x);
+int jpc_floorlog2(int_fast32_t x);
 
 #endif