Message ID | 20201013023427.59882-1-chris@miceli.net.au |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel] libavfilter/dnn_backend_native: chk mem allocation | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make_warn | warning | New warnings during build |
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | warning | Make failed |
Please disregard this for the replacement titled: libavfilter/dnn_backend_native: check mem allocation. Thanks, *Chris Miceli* On Tue, Oct 13, 2020 at 1:34 PM Chris Miceli <chris@miceli.net.au> wrote: > A report on Trac came in about this failure scenario where there are > potential failures to allocate memory which are going unchecked in the > code. This should fix that error in the same way that other parts of the > codebase already handle similar situations > --- > libavfilter/dnn/dnn_backend_native.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/libavfilter/dnn/dnn_backend_native.c > b/libavfilter/dnn/dnn_backend_native.c > index d45e211f0c..06980de6e7 100644 > --- a/libavfilter/dnn/dnn_backend_native.c > +++ b/libavfilter/dnn/dnn_backend_native.c > @@ -80,7 +80,15 @@ 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(); > + if (!in_frame) { > + av_log(&native_model->ctx, AV_LOG_ERROR, "Could not allocate > in_frame memory\n"); > + return DNN_ERROR; > + } > AVFrame *out_frame = av_frame_alloc(); > + if (!out_frame) { > + av_log(&native_model->ctx, AV_LOG_ERROR, "Could not allocate > out_frame memory\n"); > + return DNN_ERROR; > + } > in_frame->width = input_width; > in_frame->height = input_height; > > -- > 2.28.0 > >
diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index d45e211f0c..06980de6e7 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -80,7 +80,15 @@ 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(); + if (!in_frame) { + av_log(&native_model->ctx, AV_LOG_ERROR, "Could not allocate in_frame memory\n"); + return DNN_ERROR; + } AVFrame *out_frame = av_frame_alloc(); + if (!out_frame) { + av_log(&native_model->ctx, AV_LOG_ERROR, "Could not allocate out_frame memory\n"); + return DNN_ERROR; + } in_frame->width = input_width; in_frame->height = input_height;