diff mbox

[FFmpeg-devel,1/3] vf_colorspace: Check av_frame_copy_props() return value

Message ID 20160825231459.15314-1-vittorio.giovara@gmail.com
State Accepted
Commit 6648da359114696351db7e7468f0769a7d61c387
Headers show

Commit Message

Vittorio Giovara Aug. 25, 2016, 11:14 p.m. UTC
This function can potentially allocate memory.
---
Please keep me in CC.
Vittorio

 libavfilter/vf_colorspace.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Ronald S. Bultje Aug. 26, 2016, 4:59 a.m. UTC | #1
Hi,

On Thu, Aug 25, 2016 at 7:14 PM, Vittorio Giovara <
vittorio.giovara@gmail.com> wrote:

> This function can potentially allocate memory.
> ---
> Please keep me in CC.
> Vittorio
>
>  libavfilter/vf_colorspace.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
> index 3d39f13..bf51c83 100644
> --- a/libavfilter/vf_colorspace.c
> +++ b/libavfilter/vf_colorspace.c
> @@ -861,7 +861,11 @@ static int filter_frame(AVFilterLink *link, AVFrame
> *in)
>          av_frame_free(&in);
>          return AVERROR(ENOMEM);
>      }
> -    av_frame_copy_props(out, in);
> +    res = av_frame_copy_props(out, in);
> +    if (res < 0) {
> +        av_frame_free(&in);
> +        return res;
> +    }
>
>      out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ?
>                             default_prm[FFMIN(s->user_all, CS_NB)] :
> s->user_prm;
> --
> 2.9.3


OK.

Ronald
Michael Niedermayer Aug. 27, 2016, 11:05 a.m. UTC | #2
On Fri, Aug 26, 2016 at 12:59:34AM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Thu, Aug 25, 2016 at 7:14 PM, Vittorio Giovara <
> vittorio.giovara@gmail.com> wrote:
> 
> > This function can potentially allocate memory.
> > ---
> > Please keep me in CC.
> > Vittorio
> >
> >  libavfilter/vf_colorspace.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
> > index 3d39f13..bf51c83 100644
> > --- a/libavfilter/vf_colorspace.c
> > +++ b/libavfilter/vf_colorspace.c
> > @@ -861,7 +861,11 @@ static int filter_frame(AVFilterLink *link, AVFrame
> > *in)
> >          av_frame_free(&in);
> >          return AVERROR(ENOMEM);
> >      }
> > -    av_frame_copy_props(out, in);
> > +    res = av_frame_copy_props(out, in);
> > +    if (res < 0) {
> > +        av_frame_free(&in);
> > +        return res;
> > +    }
> >
> >      out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ?
> >                             default_prm[FFMIN(s->user_all, CS_NB)] :
> > s->user_prm;
> > --
> > 2.9.3
> 
> 
> OK.

applied

thx

[...]
diff mbox

Patch

diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 3d39f13..bf51c83 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -861,7 +861,11 @@  static int filter_frame(AVFilterLink *link, AVFrame *in)
         av_frame_free(&in);
         return AVERROR(ENOMEM);
     }
-    av_frame_copy_props(out, in);
+    res = av_frame_copy_props(out, in);
+    if (res < 0) {
+        av_frame_free(&in);
+        return res;
+    }
 
     out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ?
                            default_prm[FFMIN(s->user_all, CS_NB)] : s->user_prm;