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

Guo, Yejun yejun.guo at intel.com
Tue Aug 20 04:13:45 EEST 2019



> -----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.

> --
> 1.7.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list