check that frame allocations return non-null.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -79,8 +79,23 @@ static DNNReturnType get_output_native(void *model, const char *input_name, int · 78 unmodified lines | |||
| 79 | { | 79 | { |
| 80 | DNNReturnType ret; | 80 | DNNReturnType ret; |
| 81 | NativeModel *native_model = (NativeModel *)model; | 81 | NativeModel *native_model = (NativeModel *)model; |
| 82 | NativeContext *ctx = &native_model->ctx; | ||
| 82 | AVFrame *in_frame = av_frame_alloc(); | 83 | AVFrame *in_frame = av_frame_alloc(); |
| 83 | AVFrame *out_frame = av_frame_alloc(); | 84 | AVFrame *out_frame = NULL; |
| 85 | |||
| 86 | if (!in_frame) { | ||
| 87 | av_log(ctx, AV_LOG_ERROR, "Could not allocate memory for input frame\n"); | ||
| 88 | return DNN_ERROR; | ||
| 89 | } | ||
| 90 | |||
| 91 | out_frame = av_frame_alloc(); | ||
| 92 | |||
| 93 | if (!out_frame) { | ||
| 94 | av_log(ctx, AV_LOG_ERROR, "Could not allocate memory for output frame\n"); | ||
| 95 | av_frame_free(&in_frame); | ||
| 96 | return DNN_ERROR; | ||
| 97 | } | ||
| 98 | |||
| 84 | in_frame->width = input_width; | 99 | in_frame->width = input_width; |
| 85 | in_frame->height = input_height; | 100 | in_frame->height = input_height; |
| 86 | 101 | ||