[FFmpeg-soc] [soc]: r977 - jpeg2000/j2kdec.c

k.nowosad subversion at mplayerhq.hu
Sat Aug 18 22:46:16 CEST 2007


Author: k.nowosad
Date: Sat Aug 18 22:46:16 2007
New Revision: 977

Log:
added missing malloc checks


Modified:
   jpeg2000/j2kdec.c

Modified: jpeg2000/j2kdec.c
==============================================================================
--- jpeg2000/j2kdec.c	(original)
+++ jpeg2000/j2kdec.c	Sat Aug 18 22:46:16 2007
@@ -318,10 +318,15 @@ static int get_siz(J2kDecoderContext *s)
     s->numYtiles = ff_j2k_ceildiv(s->Ysiz - s->YT0siz, s->YTsiz);
 
     s->tile = av_mallocz(s->numXtiles * s->numYtiles * sizeof(J2kTile));
+    if (!s->tile)
+        return -1;
+
     for (i = 0; i < s->numXtiles * s->numYtiles; i++){
         J2kTile *tile = s->tile + i;
 
         tile->comp = av_mallocz(s->ncomponents * sizeof(J2kComponent));
+        if (!tile->comp)
+            return -1;
     }
 
     s->avctx->width = s->Xsiz - s->X0siz;
@@ -626,6 +631,8 @@ static int init_tile(J2kDecoderContext *
                                                               prec->yi1 - prec->yi0);
                         prec->zerobits = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
                                                               prec->yi1 - prec->yi0);
+                        if (!prec->cblkincl || !prec->zerobits)
+                            return -1;
 
                     }
                     xi1 += cblkperprecw;
@@ -904,6 +911,9 @@ static int dwt_decode53(J2kDecoderContex
     int *ppv = av_malloc((comp->reslevel[lev-1].y1 + 4)*sizeof(int)), *pv = ppv+2;
     int *ppu = av_malloc((comp->reslevel[lev-1].x1 + 4)*sizeof(int)), *pu = ppu+2;
 
+    if (!ppv || !ppu)
+        return -1;
+
     for (i = 1; i < lev; i++){
         int u0 = comp->reslevel[i].x0,
             u1 = comp->reslevel[i].x1,
@@ -960,6 +970,9 @@ static int dwt_decode97(J2kDecoderContex
     float *ppv = av_malloc((comp->reslevel[lev-1].y1 + 8)*sizeof(float)), *pv = ppv+4;
     float *ppu = av_malloc((comp->reslevel[lev-1].x1 + 8)*sizeof(float)), *pu = ppu+4;
 
+    if (!ppv || !ppu)
+        return -1;
+
     for (i = 1; i < lev; i++){
         int u0 = comp->reslevel[i].x0,
             u1 = comp->reslevel[i].x1,



More information about the FFmpeg-soc mailing list