Merge pull request #636 from uclouvain/opj_malloc-625
authorMatthieu Darbois <mayeut@users.noreply.github.com>
Sun, 18 Oct 2015 01:14:55 +0000 (03:14 +0200)
committerMatthieu Darbois <mayeut@users.noreply.github.com>
Sun, 18 Oct 2015 01:14:55 +0000 (03:14 +0200)
Update allocation functions
Fix #625
Fix #624
Fix #635

1  2 
src/lib/openjp2/dwt.c

diff --combined src/lib/openjp2/dwt.c
index eead5865de144ca8925aae80b8379feb8bc5c9b9,41dca2fe7e4c30730840c141605dbc00de9b473f..92752f4289821352dd624ca46d3bb76a27420df2
@@@ -567,9 -567,11 +567,11 @@@ static OPJ_BOOL opj_dwt_decode_tile(opj
        OPJ_UINT32 rh = (OPJ_UINT32)(tr->y1 - tr->y0);  /* height of the resolution level computed */
  
        OPJ_UINT32 w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
-       h.mem = (OPJ_INT32*)
-       opj_aligned_malloc(opj_dwt_max_resolution(tr, numres) * sizeof(OPJ_INT32));
+       
+       if (numres == 1U) {
+               return OPJ_TRUE;
+       }
+       h.mem = (OPJ_INT32*)opj_aligned_malloc(opj_dwt_max_resolution(tr, numres) * sizeof(OPJ_INT32));
        if (! h.mem){
                /* FIXME event manager error callback */
                return OPJ_FALSE;
@@@ -741,8 -743,8 +743,8 @@@ static void opj_v4dwt_decode_step1(opj_
  
  static void opj_v4dwt_decode_step2(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32 m, OPJ_FLOAT32 c)
  {
 -      OPJ_FLOAT32* restrict fl = (OPJ_FLOAT32*) l;
 -      OPJ_FLOAT32* restrict fw = (OPJ_FLOAT32*) w;
 +      OPJ_FLOAT32* fl = (OPJ_FLOAT32*) l;
 +      OPJ_FLOAT32* fw = (OPJ_FLOAT32*) w;
        OPJ_INT32 i;
        for(i = 0; i < m; ++i){
                OPJ_FLOAT32 tmp1_1 = fl[0];