fixed segfault with 123.j2c and bug.j2c images (thanks to Tim Mattox for his contribu...
authorMickael Savinaud <savmickael@users.noreply.github.com>
Wed, 10 Aug 2011 09:00:34 +0000 (09:00 +0000)
committerMickael Savinaud <savmickael@users.noreply.github.com>
Wed, 10 Aug 2011 09:00:34 +0000 (09:00 +0000)
CHANGES
libopenjpeg/tcd.c

diff --git a/CHANGES b/CHANGES
index 8ee45225a3eff6ba4a9ce572a8acc67e3225eea0..9402b7de6c27c125f2257fa1160eb61b367cdd3b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,7 @@ August 10, 2011
 ! [mickael] removed unused parameters warnings with the solution proposed by myself and Bob Friesenhahn.
 ! [mickael] add copyright header into new test functions.
 * [mickael] fixed glibc error with broken2 and broken4 images.
+* [mickael] fixed segfault with 123.j2c and bug.j2c images (thanks to Tim Mattox for his improvement).
 
 August 9, 2011
 - [antonin] removed xcode project files (cmake and autotools are now the only supported build methods)
index fc25179a7bae6c82a0f6d0efaa7c0247915e4436..9c7bcc0dd230d56a8986a018f36b9c606addb90a 100644 (file)
@@ -1418,18 +1418,23 @@ opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno
 
        if (tcd->tcp->mct) {
                int n = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0);
-               if (tcd->tcp->tccps[0].qmfbid == 1) {
-                       mct_decode(
-                                       tile->comps[0].data,
-                                       tile->comps[1].data,
-                                       tile->comps[2].data, 
-                                       n);
-               } else {
-                       mct_decode_real(
-                                       (float*)tile->comps[0].data,
-                                       (float*)tile->comps[1].data,
-                                       (float*)tile->comps[2].data, 
-                                       n);
+
+               if (tile->numcomps >= 3 ){
+                       if (tcd->tcp->tccps[0].qmfbid == 1) {
+                               mct_decode(
+                                               tile->comps[0].data,
+                                               tile->comps[1].data,
+                                               tile->comps[2].data,
+                                               n);
+                       } else {
+                               mct_decode_real(
+                                               (float*)tile->comps[0].data,
+                                               (float*)tile->comps[1].data,
+                                               (float*)tile->comps[2].data,
+                                               n);
+                       }
+               } else{
+                       opj_event_msg(tcd->cinfo, EVT_WARNING,"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",tile->numcomps);
                }
        }