diff options
author | Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> | 2014-04-30 15:59:04 +0100 |
---|---|---|
committer | Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> | 2014-04-30 18:18:50 +0100 |
commit | 3529de17842562aaf5c07df08cb65957556bdcd3 (patch) | |
tree | db32eb6770fadfe91897262c4b3d17afd4506cbe | |
parent | 6d92f18d1b3ea9dd40a4feb0f953e938895a8a83 (diff) |
avvidenc: guard against division by zero
and other nonsensical time base values while we're at it.
Coverity 1139699
-rw-r--r-- | ext/libav/gstavvidenc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/libav/gstavvidenc.c b/ext/libav/gstavvidenc.c index bbf3f0d4e9..c01efaf6d6 100644 --- a/ext/libav/gstavvidenc.c +++ b/ext/libav/gstavvidenc.c @@ -381,6 +381,11 @@ gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder, /* fetch pix_fmt, fps, par, width, height... */ gst_ffmpeg_videoinfo_to_context (&state->info, ffmpegenc->context); + /* sanitize time base */ + if (ffmpegenc->context->time_base.num <= 0 + || ffmpegenc->context->time_base.den <= 0) + goto insane_timebase; + if ((oclass->in_plugin->id == AV_CODEC_ID_MPEG4) && (ffmpegenc->context->time_base.den > 65535)) { /* MPEG4 Standards do not support time_base denominator greater than @@ -529,6 +534,13 @@ unsupported_codec: GST_DEBUG ("Unsupported codec - no caps found"); return FALSE; } + +insane_timebase: + { + GST_ERROR_OBJECT (ffmpegenc, "Rejecting time base %d/%d", + ffmpegenc->context->time_base.den, ffmpegenc->context->time_base.num); + return FALSE; + } } |