[FFmpeg-cvslog] wavpack: Check error codes rather than working around error conditions.

Alex Converse git at videolan.org
Sat Oct 1 22:47:31 CEST 2011


ffmpeg | branch: release/0.8 | Alex Converse <alex.converse at gmail.com> | Thu Sep  8 11:02:43 2011 -0700| [5d4c065476da547fd1a8a604e3047e1b3a7a29d8] | committer: Reinhard Tartler

wavpack: Check error codes rather than working around error conditions.

(cherry picked from commit dba2b63a98bdcac7bda1a8a2c48950518c075e17)

Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

 libavcodec/wavpack.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 343120f..f614c7a 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -1119,6 +1119,10 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
             samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
         else
             samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
+
+        if (samplecount < 0)
+            return -1;
+
         samplecount >>= 1;
     }else{
         const int channel_stride = avctx->channels;
@@ -1130,11 +1134,14 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
         else
             samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
 
+        if (samplecount < 0)
+            return -1;
+
         if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16){
             int16_t *dst = (int16_t*)samples + 1;
             int16_t *src = (int16_t*)samples;
             int cnt = samplecount;
-            while(cnt-- > 0){
+            while(cnt--){
                 *dst = *src;
                 src += channel_stride;
                 dst += channel_stride;
@@ -1143,7 +1150,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
             int32_t *dst = (int32_t*)samples + 1;
             int32_t *src = (int32_t*)samples;
             int cnt = samplecount;
-            while(cnt-- > 0){
+            while(cnt--){
                 *dst = *src;
                 src += channel_stride;
                 dst += channel_stride;
@@ -1152,7 +1159,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
             float *dst = (float*)samples + 1;
             float *src = (float*)samples;
             int cnt = samplecount;
-            while(cnt-- > 0){
+            while(cnt--){
                 *dst = *src;
                 src += channel_stride;
                 dst += channel_stride;



More information about the ffmpeg-cvslog mailing list