[FFmpeg-devel] [PATCH 2/3] hwcontext_vaapi: Return error if can not find a VA RT format

Xiang, Haihao haihao.xiang at intel.com
Tue May 8 05:53:53 EEST 2018


On Mon, 2018-05-07 at 21:48 +0100, Mark Thompson wrote:
> On 04/05/18 15:41, Haihao Xiang wrote:
> > Otherwise va_rt_format might be unitialized
> > 
> > Signed-off-by: Haihao Xiang <haihao.xiang at intel.com>
> > ---
> >  libavutil/hwcontext_vaapi.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> > index 7daaa951cc..e59042487d 100644
> > --- a/libavutil/hwcontext_vaapi.c
> > +++ b/libavutil/hwcontext_vaapi.c
> > @@ -1028,6 +1028,11 @@ static int vaapi_map_from_drm(AVHWFramesContext
> > *src_fc, AVFrame *dst,
> >              va_rt_format = vaapi_format_map[i].rt_format;
> >      }
> >  
> > +    if (i >= FF_ARRAY_ELEMS(vaapi_format_map)) {
> > +        av_log(dst_fc, AV_LOG_ERROR, "No matching VA RT format \n");
> > +        return AVERROR(EINVAL);
> > +    }
> > +
> >      buffer_handle = desc->objects[0].fd;
> >      buffer_desc.pixel_format = va_fourcc;
> >      buffer_desc.width        = src_fc->width;
> > 
> 
> How would you hit this case?  Every fourcc in vaapi_drm_format_map is also
> present in vaapi_format_map.

It is reported by static analysis tool as well. I think adding a check here make
s sure the relationship between vaapi_drm_format_map and vaapi_format_map. or
how about av_assert0(i < FF_ARRAY_ELEMS(vaapi_format_map)) if you don't want to
add the if()?

> 
> - Mark
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list