summaryrefslogtreecommitdiff
path: root/libavcodec/8svx.c
diff options
context:
space:
mode:
authorNicolas George <nicolas.george@normalesup.org>2012-07-31 23:45:16 +0200
committerNicolas George <nicolas.george@normalesup.org>2012-08-01 10:29:10 +0200
commit6eee9f5596074f9c0ff2cb25050b56c2914ff411 (patch)
tree606d08cfb0dbdeffbfe17ee6438ecd8e2b4da3b7 /libavcodec/8svx.c
parentd1ebb25ac6ef9348e5f27c38be0971198810999d (diff)
8svx: ensure that packet size is multiple of channels.
Fix an assert failure with packets of invalid size.
Diffstat (limited to 'libavcodec/8svx.c')
-rw-r--r--libavcodec/8svx.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c
index e89b252218..8d6a6d692e 100644
--- a/libavcodec/8svx.c
+++ b/libavcodec/8svx.c
@@ -112,9 +112,16 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
/* decode and interleave the first packet */
if (!esc->samples && avpkt) {
uint8_t *deinterleaved_samples, *p = NULL;
+ int packet_size = avpkt->size;
+ if (packet_size % avctx->channels) {
+ av_log(avctx, AV_LOG_WARNING, "Packet with odd size, ignoring last byte\n");
+ if (packet_size < avctx->channels)
+ return packet_size;
+ packet_size -= packet_size % avctx->channels;
+ }
esc->samples_size = !esc->table ?
- avpkt->size : avctx->channels + (avpkt->size-avctx->channels) * 2;
+ packet_size : avctx->channels + (packet_size-avctx->channels) * 2;
if (!(esc->samples = av_malloc(esc->samples_size)))
return AVERROR(ENOMEM);