aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vmdav.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-30 10:23:50 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-30 10:36:52 +0200
commit103ffde5a3914c33a34a951a3f4086801dbe4938 (patch)
treeba8e42bdcb2044d80409f0964d7752119bb97966 /libavcodec/vmdav.c
parentab78e21ea285309b3d0a997a06cf993ff45b9fdc (diff)
parent701966730ce10290fd49c5ccedd73f505680f764 (diff)
downloadffmpeg-103ffde5a3914c33a34a951a3f4086801dbe4938.tar.gz
Merge commit '701966730ce10290fd49c5ccedd73f505680f764'
* commit '701966730ce10290fd49c5ccedd73f505680f764': vmd: drop incomplete chunks and spurious samples Conflicts: libavcodec/vmdav.c 2 of the changes are replaced by assert0s, as they should be impossible. The actual bug is likely caused by a invalid block_align which is checked for and thus impossible in ffmpeg. Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vmdav.c')
-rw-r--r--libavcodec/vmdav.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c
index ac2180cf05..40c1fd27e8 100644
--- a/libavcodec/vmdav.c
+++ b/libavcodec/vmdav.c
@@ -43,6 +43,7 @@
#include <stdlib.h>
#include <string.h>
+#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
@@ -588,6 +589,9 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
/* ensure output buffer is large enough */
audio_chunks = buf_size / s->chunk_size;
+ /* drop incomplete chunks */
+ buf_size = audio_chunks * s->chunk_size;
+
/* get output buffer */
frame->nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) /
avctx->channels;
@@ -599,6 +603,8 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
/* decode silent chunks */
if (silent_chunks > 0) {
int silent_size = avctx->block_align * silent_chunks;
+ av_assert0(avctx->block_align * silent_chunks <= frame->nb_samples * avctx->channels);
+
if (s->out_bps == 2) {
memset(output_samples_s16, 0x00, silent_size * 2);
output_samples_s16 += silent_size;
@@ -611,6 +617,7 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
/* decode audio chunks */
if (audio_chunks > 0) {
buf_end = buf + buf_size;
+ av_assert0((buf_size & (avctx->channels > 1)) == 0);
while (buf_end - buf >= s->chunk_size) {
if (s->out_bps == 2) {
decode_audio_s16(output_samples_s16, buf, s->chunk_size,