diff options
author | Chris Miceli <chris@miceli.net.au> | 2020-10-14 11:19:50 +1100 |
---|---|---|
committer | Guo, Yejun <yejun.guo@intel.com> | 2020-10-14 10:19:05 +0800 |
commit | ad95e5e45dbb3c3dddc3e2c3fe93bc98f239bd29 (patch) | |
tree | 020a49a6b04a6246a1e85816409c0cf047da3854 | |
parent | 00772ef4f7c87e708b5292a696c3efc78d234366 (diff) |
libavfilter/dnn_backend_native: check mem allocation
check that frame allocations return non-null.
-rw-r--r-- | libavfilter/dnn/dnn_backend_native.c | 17 |
1 files changed, 16 insertions, 1 deletions
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; + } + in_frame->width = input_width; in_frame->height = input_height; |