diff mbox series

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

Message ID 20201013051558.198897-1-chris@miceli.net.au
State Superseded
Headers show
Series [FFmpeg-devel] libavfilter/dnn_backend_native: check mem allocation | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make warning Make failed

Commit Message

Chris Miceli Oct. 13, 2020, 5:15 a.m. UTC
check that frame allocations return non-null.
---
 libavfilter/dnn/dnn_backend_native.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Guo, Yejun Oct. 13, 2020, 8:08 a.m. UTC | #1
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Chris
> Miceli
> Sent: 2020年10月13日 13:16
> To: ffmpeg-devel@ffmpeg.org
> Cc: Chris Miceli <chris@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 | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/dnn/dnn_backend_native.c
> b/libavfilter/dnn/dnn_backend_native.c
> index d45e211f0c..7958ceb4f7 100644
> --- a/libavfilter/dnn/dnn_backend_native.c
> +++ b/libavfilter/dnn/dnn_backend_native.c
> @@ -80,7 +80,18 @@ static DNNReturnType get_output_native(void *model,
> const char *input_name, int
>      DNNReturnType ret;
>      NativeModel *native_model = (NativeModel *)model;
>      AVFrame *in_frame = av_frame_alloc();
> -    AVFrame *out_frame = av_frame_alloc();
> +    AVFrame *out_frame = NULL;
> +
> +    if (!in_frame)
> +        return DNN_ERROR;
> +
> +    out_frame = av_frame_alloc();
> +
> +    if (!out_frame) {
> +        av_frame_free(&in_frame);
> +        return DNN_ERROR;
> +    }
> +

could you add some log message just like your first patch? thanks.

and, could you also fix the same issue in get_output_ov and get_output_tf if you'd like, thanks.
diff mbox series

Patch

diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c
index d45e211f0c..7958ceb4f7 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -80,7 +80,18 @@  static DNNReturnType get_output_native(void *model, const char *input_name, int
     DNNReturnType ret;
     NativeModel *native_model = (NativeModel *)model;
     AVFrame *in_frame = av_frame_alloc();
-    AVFrame *out_frame = av_frame_alloc();
+    AVFrame *out_frame = NULL;
+
+    if (!in_frame)
+        return DNN_ERROR;
+
+    out_frame = av_frame_alloc();
+
+    if (!out_frame) {
+        av_frame_free(&in_frame);
+        return DNN_ERROR;
+    }
+
     in_frame->width = input_width;
     in_frame->height = input_height;