aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/jvdec.c
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2014-02-12 20:08:52 +0100
committerJanne Grunau <janne-libav@jannau.net>2014-02-12 20:12:18 +0100
commit8a2250344b19a343d830a902dbcf4c0b929ea49b (patch)
tree82ffa0527a0d3fedd60947b1af6c1f602add9698 /libavformat/jvdec.c
parentf795a8a8bf5e312dad2c2829c543b9d309376ca1 (diff)
downloadffmpeg-8a2250344b19a343d830a902dbcf4c0b929ea49b.tar.gz
jv: detect partial packets in the demuxer
Fixes fate-jv under valgrind which reports a different CRC for the last frame from a partial read.
Diffstat (limited to 'libavformat/jvdec.c')
-rw-r--r--libavformat/jvdec.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index 006acec7bc..84d55daad1 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -184,16 +184,22 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
case JV_VIDEO:
jv->state++;
if (jvf->video_size || jvf->palette_size) {
+ int ret;
int size = jvf->video_size + jvf->palette_size;
if (av_new_packet(pkt, size + JV_PREAMBLE_SIZE))
return AVERROR(ENOMEM);
AV_WL32(pkt->data, jvf->video_size);
pkt->data[4] = jvf->video_type;
- if (avio_read(pb, pkt->data + JV_PREAMBLE_SIZE, size) < 0)
- return AVERROR(EIO);
-
- pkt->size = size + JV_PREAMBLE_SIZE;
+ ret = avio_read(pb, pkt->data + JV_PREAMBLE_SIZE, size);
+ if (ret < 0)
+ return ret;
+ if (ret < size) {
+ memset(pkt->data + JV_PREAMBLE_SIZE + ret, 0,
+ FF_INPUT_BUFFER_PADDING_SIZE);
+ pkt->flags |= AV_PKT_FLAG_CORRUPT;
+ }
+ pkt->size = ret + JV_PREAMBLE_SIZE;
pkt->stream_index = 1;
pkt->pts = jv->pts;
if (jvf->video_type != 1)