changeset 4690:1bfdcac74275 libavcodec

Correctly handle data_size on decoding
author kostya
date Tue, 20 Mar 2007 05:44:42 +0000
parents c7828f1ae244
children 0f596a49ba3d
files wavpack.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/wavpack.c	Tue Mar 20 02:12:13 2007 +0000
+++ b/wavpack.c	Tue Mar 20 05:44:42 2007 +0000
@@ -383,14 +383,20 @@
     uint8_t* buf_end = buf + buf_size;
     int i, j, id, size, ssize, weights, t;
 
-    if (buf_size == 0) return 0;
+    if (buf_size == 0){
+        *data_size = 0;
+        return 0;
+    }
 
     memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
 
     s->samples = AV_RL32(buf); buf += 4;
-    if(!s->samples) return buf_size;
+    if(!s->samples){
+        *data_size = 0;
+        return buf_size;
+    }
     /* should not happen but who knows */
-    if(s->samples * 2 * avctx->channels > AVCODEC_MAX_AUDIO_FRAME_SIZE){
+    if(s->samples * 2 * avctx->channels > *data_size){
         av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");
         return -1;
     }