[FFmpeg-devel] [PATCH] libavfilter/dnn_backend_native: check mem allocation

Guo, Yejun yejun.guo at intel.com
Wed Oct 14 05:32:31 EEST 2020



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Chris
> Miceli
> Sent: 2020年10月14日 8:20
> To: ffmpeg-devel at ffmpeg.org
> Cc: Chris Miceli <chris at miceli.net.au>
> Subject: [FFmpeg-devel] [PATCH] libavfilter/dnn_backend_native: check mem
> allocation
> 
> check that frame allocations return non-null.
> ---
>  libavfilter/dnn/dnn_backend_native.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/dnn/dnn_backend_native.c
> b/libavfilter/dnn/dnn_backend_native.c
> index d45e211f0c..4fc3ba2044 100644
> --- a/libavfilter/dnn/dnn_backend_native.c
> +++ b/libavfilter/dnn/dnn_backend_native.c
> @@ -79,8 +79,23 @@ static DNNReturnType get_output_native(void *model,
> const char *input_name, int  {
>      DNNReturnType ret;
>      NativeModel *native_model = (NativeModel *)model;
> +    NativeContext *ctx = &native_model->ctx;
>      AVFrame *in_frame = av_frame_alloc();
> -    AVFrame *out_frame = av_frame_alloc();
> +    AVFrame *out_frame = NULL;
> +
> +    if (!in_frame) {
> +        av_log(ctx, AV_LOG_ERROR, "Could not allocate memory for input
> frame\n");
> +        return DNN_ERROR;
> +    }
> +
> +    out_frame = av_frame_alloc();
> +
> +    if (!out_frame) {
> +        av_log(ctx, AV_LOG_ERROR, "Could not allocate memory for output
> frame\n");
> +        av_frame_free(&in_frame);
> +        return DNN_ERROR;
> +    }
> +
LGTM, will push soon, thanks.


More information about the ffmpeg-devel mailing list