diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-05-02 18:38:41 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-05-16 10:30:57 +0200 |
commit | e62ff72fc1052273deb708ba715f73e5187281d4 (patch) | |
tree | ca8c6ad329605a8305eec403e4ca8f80db9c09c9 | |
parent | 11de006babf735aafa3462d43dd2c02bb6ac6e2f (diff) | |
download | ffmpeg-e62ff72fc1052273deb708ba715f73e5187281d4.tar.gz |
lavc: make avcodec_open2() fail when the timebase is not set for encoding
Many encoders use it. There is also a divide by the timebase lower in
this function, which would crash when it is not set.
-rw-r--r-- | libavcodec/utils.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index d42885dcb1..a0352b80a0 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -994,6 +994,13 @@ FF_DISABLE_DEPRECATION_WARNINGS } FF_ENABLE_DEPRECATION_WARNINGS #endif + + if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) { + av_log(avctx, AV_LOG_ERROR, "The encoder timebase is not set.\n"); + ret = AVERROR(EINVAL); + goto free_and_end; + } + if (avctx->codec->sample_fmts) { for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) { if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) |