avformat/mov: Check dimensions before setting aspect

Fixes division by 0
Fixes: asan_heap-uaf_143f420_728_cov_1441472032_HDV_0113.MP4

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/111/head
Michael Niedermayer 10 years ago
parent b74ecb82fa
commit 5763f67502
  1. 3
      libavformat/mov.c

@ -2630,7 +2630,8 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
} }
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!st->sample_aspect_ratio.num && if (!st->sample_aspect_ratio.num && st->codec->width && st->codec->height &&
sc->height && sc->width &&
(st->codec->width != sc->width || st->codec->height != sc->height)) { (st->codec->width != sc->width || st->codec->height != sc->height)) {
st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) / st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) /
((double)st->codec->width * sc->height), INT_MAX); ((double)st->codec->width * sc->height), INT_MAX);

Loading…
Cancel
Save