]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Move block size check to decoder
authorkostya <kostya@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sat, 14 Oct 2006 05:01:05 +0000 (05:01 +0000)
committerkostya <kostya@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sat, 14 Oct 2006 05:01:05 +0000 (05:01 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@6688 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/wavpack.c
libavformat/wv.c

index 75456afe2e0637f4ab9eace6da0642261089c198..53ba34b69dd1b0c0325ba70b9d64f9c19d3519a8 100644 (file)
@@ -388,6 +388,11 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
     memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
 
     s->samples = LE_32(buf); buf += 4;
+    /* should not happen but who knows */
+    if(s->samples * 2 * avctx->channels > AVCODEC_MAX_AUDIO_FRAME_SIZE){
+        av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");
+        return -1;
+    }
     s->joint = LE_32(buf) & WV_JOINT; buf += 4;
     s->CRC = LE_32(buf); buf += 4;
     // parse metadata blocks
index 170755c4ddbc6e2a717eed725a9549b8842c2ae9..e601c05fcbc0518b2ad594de474c037f7e2cce05 100644 (file)
@@ -171,12 +171,6 @@ static int wv_read_packet(AVFormatContext *s,
             return -1;
     }
 
-    samples = LE_32(wc->extra);
-    /* should not happen but who knows */
-    if(samples * 2 * wc->chan > AVCODEC_MAX_AUDIO_FRAME_SIZE){
-        av_log(s, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");
-        return -EIO;
-    }
     if(av_new_packet(pkt, wc->blksize + WV_EXTRA_SIZE) < 0)
         return AVERROR_NOMEM;
     memcpy(pkt->data, wc->extra, WV_EXTRA_SIZE);