aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2014-10-24 13:15:36 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-01-13 00:05:27 +0100
commit242fc6394fecb403bcbd0f652920f2647d0b08ae (patch)
tree6a62c93fd72d8f8307ab7ffcf196f27e77e06cb4
parentbae05e5326703dad3bfe0ed5b31ba73ee9254515 (diff)
downloadffmpeg-242fc6394fecb403bcbd0f652920f2647d0b08ae.tar.gz
mtv: improve header check and avoid division by zero
CC: libav-stable@libav.org Bug-Id: CID 732203 / CID 732204
-rw-r--r--libavformat/mtv.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/mtv.c b/libavformat/mtv.c
index 5a7f0477ff..7ad7618434 100644
--- a/libavformat/mtv.c
+++ b/libavformat/mtv.c
@@ -96,14 +96,17 @@ static int mtv_read_header(AVFormatContext *s)
/* Calculate width and height if missing from header */
- if(!mtv->img_width)
+ if (!mtv->img_width && mtv->img_height > 0 && mtv->img_bpp >= 8)
mtv->img_width=mtv->img_segment_size / (mtv->img_bpp>>3)
/ mtv->img_height;
- if(!mtv->img_height)
+ if (!mtv->img_height && mtv->img_width > 0 && mtv->img_bpp >= 8)
mtv->img_height=mtv->img_segment_size / (mtv->img_bpp>>3)
/ mtv->img_width;
+ if (!mtv->img_width || !mtv->img_height)
+ return AVERROR_INVALIDDATA;
+
avio_skip(pb, 4);
audio_subsegments = avio_rl16(pb);