diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-10-29 23:25:51 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-10-29 23:27:33 +0300 |
commit | 9a534eda4608b76fa0c958e876025b2c639aeb63 (patch) | |
tree | cec9c653268a64a539d3827c88c216914a6d6ef6 /libavformat/mtv.c | |
parent | e08ff208c7934754e408f3985a68833f8c4b69c3 (diff) | |
parent | f64d7e919eabd427f3e6dd4a1219e448c78deb42 (diff) |
Merge commit 'f64d7e919eabd427f3e6dd4a1219e448c78deb42'
* commit 'f64d7e919eabd427f3e6dd4a1219e448c78deb42':
mtv: improve header check and avoid division by zero
Conflicts:
libavformat/mtv.c
See: 8b9b6332dfeb169098c8ab1351d66fc5b474dd55
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mtv.c')
-rw-r--r-- | libavformat/mtv.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libavformat/mtv.c b/libavformat/mtv.c index 1d5f26673a..addad24440 100644 --- a/libavformat/mtv.c +++ b/libavformat/mtv.c @@ -112,7 +112,7 @@ static int mtv_read_header(AVFormatContext *s) mtv->audio_identifier = avio_rl24(pb); mtv->audio_br = avio_rl16(pb); mtv->img_colorfmt = avio_rl24(pb); - mtv->img_bpp = avio_r8(pb)>>3; + mtv->img_bpp = avio_r8(pb); mtv->img_width = avio_rl16(pb); mtv->img_height = avio_rl16(pb); mtv->img_segment_size = avio_rl16(pb); @@ -128,17 +128,17 @@ static int mtv_read_header(AVFormatContext *s) /* Calculate width and height if missing from header */ - if(!mtv->img_width && mtv->img_height) - mtv->img_width=mtv->img_segment_size / (mtv->img_bpp) + 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 && mtv->img_width) - mtv->img_height=mtv->img_segment_size / (mtv->img_bpp) + 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_height || !mtv->img_width || !mtv->img_segment_size){ av_log(s, AV_LOG_ERROR, "width or height or segment_size is invalid and I cannot calculate them from other information\n"); - return AVERROR(EINVAL); + return AVERROR_INVALIDDATA; } avio_skip(pb, 4); |