[FFmpeg-cvslog] avcodec/pcm-dvd: discard buffer if block size changed

Michael Niedermayer git at videolan.org
Sun Sep 1 13:06:58 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Sep  1 12:36:51 2013 +0200| [7c1805869d6f8dd9292977393aa4d97417716852] | committer: Michael Niedermayer

avcodec/pcm-dvd: discard buffer if block size changed

This prevents a potential crash

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

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

 libavcodec/pcm-dvd.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
index f3f02cf..b984969 100644
--- a/libavcodec/pcm-dvd.c
+++ b/libavcodec/pcm-dvd.c
@@ -31,6 +31,7 @@
 typedef struct PCMDVDContext {
     uint32_t last_header;    // Cached header to see if parsing is needed
     int block_size;          // Size of a block of samples in bytes
+    int last_block_size;     // Size of the last block of samples in bytes
     int samples_per_block;   // Number of samples per channel per block
     int groups_per_block;    // Number of 20/24bit sample groups per block
     uint8_t *extra_samples;  // Pointer to leftover samples from a frame
@@ -223,6 +224,11 @@ static int pcm_dvd_decode_frame(AVCodecContext *avctx, void *data,
 
     if ((retval = pcm_dvd_parse_header(avctx, src)))
         return retval;
+    if (s->last_block_size != s->block_size) {
+        av_log(avctx, AV_LOG_WARNING, "block_size has changed\n");
+        s->extra_sample_count = 0;
+    }
+    s->last_block_size = s->block_size;
     src      += 3;
     buf_size -= 3;
 



More information about the ffmpeg-cvslog mailing list