avcodec/jpeg2000: Check that codsty->log2_prec_widths/heights has been initialized
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 4 Sep 2017 20:23:26 +0000 (22:23 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 4 Oct 2017 23:26:58 +0000 (01:26 +0200)
Fixes: OOM
Fixes: 2225/clusterfuzz-testcase-minimized-5505632079708160

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 64e034da954125ef98fb8f9153f9706cdb8a96fe)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/jpeg2000.c

index b5b2dbf..1d6ae37 100644 (file)
@@ -506,6 +506,9 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
         // update precincts size: 2^n value
         reslevel->log2_prec_width  = codsty->log2_prec_widths[reslevelno];
         reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
+        if (!reslevel->log2_prec_width || !reslevel->log2_prec_height) {
+            return AVERROR_INVALIDDATA;
+        }
 
         /* Number of bands for each resolution level */
         if (reslevelno == 0)