From 98f8e31c0b910499c3b17906a5ccf050628f6360 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 2 Aug 2024 16:50:09 +0200 Subject: [PATCH] vcf/logo: replace assert with error messages If either encoder or decoder is not found, print the error message rather than crashing with abort(). refer to GH-403 --- src/capture_filter/logo.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/capture_filter/logo.c b/src/capture_filter/logo.c index 052ae2514..72aa28fbf 100644 --- a/src/capture_filter/logo.c +++ b/src/capture_filter/logo.c @@ -51,6 +51,7 @@ #include "utils/macros.h" #include "utils/pam.h" #include "video_codec.h" +#include "video_frame.h" // for VIDEO_FRAME_DISPOSE struct module; @@ -161,10 +162,21 @@ static struct video_frame *filter(void *state, struct video_frame *in) state; decoder_t decoder, coder; decoder = get_decoder_from_to(in->color_spec, RGB); + if (decoder == NULL) { + MSG(ERROR, "Cannot find decoder from %s to RGB!\n", + get_codec_name(in->color_spec)); + VIDEO_FRAME_DISPOSE(in); + return NULL; + } coder = get_decoder_from_to(RGB, in->color_spec); + if (coder == NULL) { + MSG(ERROR, "Cannot find encoder from %s to RGB!\n", + get_codec_name(in->color_spec)); + VIDEO_FRAME_DISPOSE(in); + return NULL; + } int rect_x = s->x; int rect_y = s->y; - assert(coder != NULL && decoder != NULL); if (decoder == NULL || coder == NULL) return in;