diff mbox series

[FFmpeg-devel,5/5] avfilter/vf_blend: fix un-checked potential memory allocation failure

Message ID 20220102145142.4083918-5-jianhua.wu@intel.com
State Accepted
Commit 49250b582ad109e04efd029cdb96020ef54fc2ee
Headers show
Series [FFmpeg-devel,1/5] avutil/hwcontext_vulkan: fixed validation error VUID 01387 | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

Wu, Jianhua Jan. 2, 2022, 2:51 p.m. UTC
Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
---
 libavfilter/vf_blend.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Lynne Jan. 3, 2022, 2:23 a.m. UTC | #1
2 Jan 2022, 15:51 by jianhua.wu-at-intel.com@ffmpeg.org:

> Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
> ---
>  libavfilter/vf_blend.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
> index b6f3c4fed3..2d433e439f 100644
> --- a/libavfilter/vf_blend.c
> +++ b/libavfilter/vf_blend.c
> @@ -279,7 +279,11 @@ static AVFrame *blend_frame(AVFilterContext *ctx, AVFrame *top_buf,
>  dst_buf = ff_get_video_buffer(outlink, outlink->w, outlink->h);
>  if (!dst_buf)
>  return top_buf;
> -    av_frame_copy_props(dst_buf, top_buf);
> +
> +    if (av_frame_copy_props(dst_buf, top_buf) < 0) {
> +        av_frame_free(&dst_buf);
> +        return top_buf;
> +    }
>  
>  for (plane = 0; plane < s->nb_planes; plane++) {
>  int hsub = plane == 1 || plane == 2 ? s->hsub : 0;
>

Pushed patches 2 and 3. The blend filter doesn't work for me:
https://0x0.st/osRM.jpg
This is not what it's meant to look like at all, for blank, default options.

Patch 1 is a driver bug. The driver should not advertise the
HDR extension as supported if there's no swapchain. The HDR
extension explicitly requires a swapchain, and the Vulkan specs
say that devices are meant to only advertise supported extensions,
which the HDR extension wouldn't be if the swapchain extension
has not been loaded.
I pushed an alternative version that just removes the HDR extension,
but you need to notify your Windows driver developers that it's
not doing what it should.
Wu, Jianhua Jan. 3, 2022, 8:39 a.m. UTC | #2
Lynne:
> Sent: Monday, January 3, 2022 10:23 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 5/5] avfilter/vf_blend: fix un-checked
> potential memory allocation failure
> 
> 2 Jan 2022, 15:51 by jianhua.wu-at-intel.com@ffmpeg.org:
> 
> > Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
> > ---
> >  libavfilter/vf_blend.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c index
> > b6f3c4fed3..2d433e439f 100644
> > --- a/libavfilter/vf_blend.c
> > +++ b/libavfilter/vf_blend.c
> > @@ -279,7 +279,11 @@ static AVFrame *blend_frame(AVFilterContext
> *ctx,
> > AVFrame *top_buf,  dst_buf = ff_get_video_buffer(outlink, outlink->w,
> > outlink->h);  if (!dst_buf)  return top_buf;
> > -    av_frame_copy_props(dst_buf, top_buf);
> > +
> > +    if (av_frame_copy_props(dst_buf, top_buf) < 0) {
> > +        av_frame_free(&dst_buf);
> > +        return top_buf;
> > +    }
> >
> >  for (plane = 0; plane < s->nb_planes; plane++) {  int hsub = plane ==
> > 1 || plane == 2 ? s->hsub : 0;
> >
> 
> Pushed patches 2 and 3. The blend filter doesn't work for me:
> https://0x0.st/osRM.jpg
> This is not what it's meant to look like at all, for blank, default options.
> 

I'm afraid of it's not the problem of the blend_vulkan filter. Could you help try the other Vulkan filters and
see if they are still work?

> Patch 1 is a driver bug. The driver should not advertise the HDR extension as
> supported if there's no swapchain. The HDR extension explicitly requires a
> swapchain, and the Vulkan specs say that devices are meant to only
> advertise supported extensions, which the HDR extension wouldn't be if the
> swapchain extension has not been loaded.
> I pushed an alternative version that just removes the HDR extension, but you
> need to notify your Windows driver developers that it's not doing what it
> should.
> 

Removing it is okay if it  is not used totally. And I' sorry we may have a mistake here.
Below is my development environment on this patch:
Operating System: Windows 10
Physical Device: Nvidia RTX3070
Driver version: GeForce Game Ready Driver 497.29
I'll add something like these to commit message if I fix similar problems.

And there is one more question, may I know why there is a suffix "@ffmpeg.org"
behind my commit Author email?

Thanks,
Jianhua
Timo Rothenpieler Jan. 3, 2022, 1:57 p.m. UTC | #3
On 03.01.2022 09:39, Wu, Jianhua wrote:
> And there is one more question, may I know why there is a suffix "@ffmpeg.org"
> behind my commit Author email?

Your E-Mail server is enforcing strict policy via DKIM/DMARC, so it's 
impossible for any other mail-servers, like mailing lists, to send 
E-Mails from @intel.com.
Hence the only option the list server has is to mangle the sender 
address like that.
Wu Jianhua Jan. 3, 2022, 2:48 p.m. UTC | #4
Timo Rothenpieler<mailto:timo@rothenpieler.org> wrote:

> On 03.01.2022 09:39, Wu, Jianhua wrote:
>> And there is one more question, may I know why there is a suffix "@ffmpeg.org"
>> behind my commit Author email?
>
> Your E-Mail server is enforcing strict policy via DKIM/DMARC, so it's
> impossible for any other mail-servers, like mailing lists, to send
> E-Mails from @intel.com.
> Hence the only option the list server has is to mangle the sender
> address like that.

Got it. Thanks for your answer. Maybe it's better to send patches as attachments in case the commit message gets broken.

Best Regards,
Jianhua
diff mbox series

Patch

diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index b6f3c4fed3..2d433e439f 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -279,7 +279,11 @@  static AVFrame *blend_frame(AVFilterContext *ctx, AVFrame *top_buf,
     dst_buf = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!dst_buf)
         return top_buf;
-    av_frame_copy_props(dst_buf, top_buf);
+
+    if (av_frame_copy_props(dst_buf, top_buf) < 0) {
+        av_frame_free(&dst_buf);
+        return top_buf;
+    }
 
     for (plane = 0; plane < s->nb_planes; plane++) {
         int hsub = plane == 1 || plane == 2 ? s->hsub : 0;