[FFmpeg-cvslog] jpeg2000: fix null pointer dereference in case of malloc failure

Michael Niedermayer git at videolan.org
Fri Aug 23 18:13:07 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Aug 23 17:50:12 2013 +0200| [9e477a37703318cb86d8ed1d426929235aa02b67] | committer: Michael Niedermayer

jpeg2000: fix null pointer dereference in case of malloc failure

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e477a37703318cb86d8ed1d426929235aa02b67
---

 libavcodec/jpeg2000.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 77bf34e..36e6ff1 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -507,17 +507,19 @@ void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
         Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
 
         for (bandno = 0; bandno < reslevel->nbands; bandno++) {
-            Jpeg2000Band *band = reslevel->band + bandno;
-            for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++) {
-                if (band->prec) {
-                    Jpeg2000Prec *prec = band->prec + precno;
-                    av_freep(&prec->zerobits);
-                    av_freep(&prec->cblkincl);
-                    av_freep(&prec->cblk);
+            if (reslevel->band) {
+                Jpeg2000Band *band = reslevel->band + bandno;
+                for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++) {
+                    if (band->prec) {
+                        Jpeg2000Prec *prec = band->prec + precno;
+                        av_freep(&prec->zerobits);
+                        av_freep(&prec->cblkincl);
+                        av_freep(&prec->cblk);
+                    }
                 }
-            }
 
-            av_freep(&band->prec);
+                av_freep(&band->prec);
+            }
         }
         av_freep(&reslevel->band);
     }



More information about the ffmpeg-cvslog mailing list