[FFmpeg-devel] [PATCH V1 4/5] lavfi/dnn/dnn_backend_native: fix memory leak in error path

mypopy at gmail.com mypopy at gmail.com
Tue Aug 20 05:01:37 EEST 2019


On Tue, Aug 20, 2019 at 9:14 AM Guo, Yejun <yejun.guo at intel.com> wrote:
>
>
>
> > -----Original Message-----
> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf Of
> > Jun Zhao
> > Sent: Monday, August 19, 2019 9:01 PM
> > To: ffmpeg-devel at ffmpeg.org
> > Cc: Jun Zhao <barryjzhao at tencent.com>
> > Subject: [FFmpeg-devel] [PATCH V1 4/5] lavfi/dnn/dnn_backend_native: fix
> > memory leak in error path
> >
> > From: Jun Zhao <barryjzhao at tencent.com>
> >
> > fix memory leak in error path
> >
> > Signed-off-by: Jun Zhao <barryjzhao at tencent.com>
> > ---
> >  libavfilter/dnn/dnn_backend_native.c |    4 ++++
> >  1 files changed, 4 insertions(+), 0 deletions(-)
> >
> > diff --git a/libavfilter/dnn/dnn_backend_native.c
> > b/libavfilter/dnn/dnn_backend_native.c
> > index 7b489d0..2619463 100644
> > --- a/libavfilter/dnn/dnn_backend_native.c
> > +++ b/libavfilter/dnn/dnn_backend_native.c
> > @@ -183,6 +183,7 @@ DNNModel *ff_dnn_load_model_native(const char
> > *model_filename)
> >              if (dnn_size > file_size || conv_params->input_num <= 0 ||
> >                  conv_params->output_num <= 0 ||
> > conv_params->kernel_size <= 0){
> >                  avio_closep(&model_file_context);
> > +                av_freep(&conv_params);
> >                  ff_dnn_free_model_native(&model);
> >                  return NULL;
> >              }
> > @@ -190,6 +191,9 @@ DNNModel *ff_dnn_load_model_native(const char
> > *model_filename)
> >              conv_params->biases = av_malloc(conv_params->output_num
> > * sizeof(float));
> >              if (!conv_params->kernel || !conv_params->biases){
> >                  avio_closep(&model_file_context);
> > +                av_freep(&conv_params->kernel);
> > +                av_freep(&conv_params->biases);
> > +                av_freep(&conv_params);
> >                  ff_dnn_free_model_native(&model);
> >                  return NULL;
> >              }
>
> LGTM, thanks.
>
Will apply, Thanks


More information about the ffmpeg-devel mailing list