ffmpeg | branch: master | Vittorio Giovara <vittorio.giov...@gmail.com> | Fri 
Oct 24 13:15:36 2014 +0100| [f64d7e919eabd427f3e6dd4a1219e448c78deb42] | 
committer: Vittorio Giovara

mtv: improve header check and avoid division by zero

CC: libav-sta...@libav.org
Bug-Id: CID 732203 / CID 732204

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

 libavformat/mtv.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/mtv.c b/libavformat/mtv.c
index 5a7f047..7ad7618 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);
 

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

Reply via email to