[FFmpeg-devel] [PATCH 3/3] avformat/v210: Check width and height

Michael Niedermayer michaelni at gmx.at
Sat Nov 21 19:20:48 CET 2015


On Fri, Nov 20, 2015 at 09:34:13PM -0800, Timothy Gu wrote:
> Fixes a floating point exception when width and height are not supplied
> (and therefore are zero).
> ---
>  libavformat/v210.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/v210.c b/libavformat/v210.c
> index ab29171..7503d5d 100644
> --- a/libavformat/v210.c
> +++ b/libavformat/v210.c
> @@ -39,6 +39,7 @@ static int v210_read_header(AVFormatContext *ctx)
>  {
>      V210DemuxerContext *s = ctx->priv_data;
>      AVStream *st;
> +    int ret;
>  
>      st = avformat_new_stream(ctx, NULL);
>      if (!st)
> @@ -50,11 +51,15 @@ static int v210_read_header(AVFormatContext *ctx)
>  
>      avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num);
>  
> +    ret = av_image_check_size(s->width, s->height, 0, ctx);
> +    if (ret < 0)
> +        return ret;
>      st->codec->width    = s->width;
>      st->codec->height   = s->height;
>      st->codec->pix_fmt  = ctx->iformat->raw_codec_id == AV_CODEC_ID_V210 ?
>                            AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV422P16;
> -    st->codec->bit_rate = av_rescale_q(GET_PACKET_SIZE(s->width, s->height),
> +    ctx->packet_size    = GET_PACKET_SIZE(s->width, s->height);
> +    st->codec->bit_rate = av_rescale_q(ctx->packet_size,
>                                         (AVRational){8,1}, st->time_base);
>  
>      return 0;
> @@ -63,18 +68,14 @@ static int v210_read_header(AVFormatContext *ctx)
>  
>  static int v210_read_packet(AVFormatContext *s, AVPacket *pkt)
>  {
> -    int packet_size, ret, width, height;
> +    int ret, width, height;

width and height are unused after this patch

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151121/e3f98fd9/attachment.sig>


More information about the ffmpeg-devel mailing list