diff mbox series

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

Message ID 20201013042357.155589-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, 4:23 a.m. UTC
check that frame allocations return non-null.
---
 libavfilter/dnn/dnn_backend_native.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Andreas Rheinhardt Oct. 13, 2020, 4:31 a.m. UTC | #1
Chris Miceli:
> check that frame allocations return non-null.
> ---
>  libavfilter/dnn/dnn_backend_native.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c
> index d45e211f0c..cda857a9c5 100644
> --- a/libavfilter/dnn/dnn_backend_native.c
> +++ b/libavfilter/dnn/dnn_backend_native.c
> @@ -81,6 +81,15 @@ static DNNReturnType get_output_native(void *model, const char *input_name, int
>      NativeModel *native_model = (NativeModel *)model;
>      AVFrame *in_frame = av_frame_alloc();
>      AVFrame *out_frame = av_frame_alloc();
> +
> +    if (!in_frame)
> +        return DNN_ERROR;
> +

out_frame may leak here.

> +    if (!out_frame) {
> +        av_frame_free(&in_frame);
> +        return DNN_ERROR;
> +    }
> +
>      in_frame->width = input_width;
>      in_frame->height = input_height;
>  
>
diff mbox series

Patch

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