[FFmpeg-devel] [PATCH] avfilter/drawutils: Check av_pix_fmt_desc_get() return value in ff_fill_line_with_color()

wm4 nfxjfg at googlemail.com
Sat Jun 13 10:31:13 CEST 2015


On Sat, 13 Jun 2015 00:05:19 +0200
Michael Niedermayer <michaelni at gmx.at> wrote:

> Theres currently no case where this could be triggered but adding this
> provides future robustness
> 
> Found-by: Daemon404
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavfilter/drawutils.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c
> index 0b2f17e..4385398 100644
> --- a/libavfilter/drawutils.c
> +++ b/libavfilter/drawutils.c
> @@ -66,7 +66,12 @@ int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t
>      uint8_t rgba_map[4] = {0};
>      int i;
>      const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt);
> -    int hsub = pix_desc->log2_chroma_w;
> +    int hsub;
> +
> +    if (!pix_desc)
> +        return AVERROR(EINVAL);
> +
> +    hsub = pix_desc->log2_chroma_w;
>  
>      *is_packed_rgba = ff_fill_rgba_map(rgba_map, pix_fmt) >= 0;
>  

I'm wondering what's the point? From what I can tell, this is a bug in
the caller, and should probably blow up with an assert. (The caller
should verify beforehand whether drawutils can handle the format.)


More information about the ffmpeg-devel mailing list