diff mbox series

[FFmpeg-devel,6/8] avfilter/tests/filtfmts: Check for existence of formats/channel layouts

Message ID AM7PR03MB6660144D8BDCA1A779DEAC7F8FAF9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 9a1547ba1e4e733aaf8d77ccc3d3576edea9f190
Headers show
Series [FFmpeg-devel,1/8] avfilter/tests/filtfmts: Replace macro by ordinary function | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 5, 2021, 8:53 p.m. UTC
Fixes segfaults with filters that either return AVERROR(EAGAIN)
(or another error) or that do not set everything and rely on
filter_query_formats() to set the rest.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/tests/filtfmts.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/tests/filtfmts.c b/libavfilter/tests/filtfmts.c
index 07e387b92e..d793480344 100644
--- a/libavfilter/tests/filtfmts.c
+++ b/libavfilter/tests/filtfmts.c
@@ -43,7 +43,7 @@  static void print_formats_internal(AVFilterLink **links, const AVFilterPad *pads
 
         if (link->type == AVMEDIA_TYPE_VIDEO) {
             const AVFilterFormats *const fmts = cfg->formats;
-            for (unsigned j = 0; j < fmts->nb_formats; j++) {
+            for (unsigned j = 0; fmts && j < fmts->nb_formats; j++) {
                 printf("%s[%u] %s: fmt:%s\n",
                         inout_string, i, pad_name,
                         av_get_pix_fmt_name(fmts->formats[j]));
@@ -52,12 +52,12 @@  static void print_formats_internal(AVFilterLink **links, const AVFilterPad *pads
             const AVFilterFormats *const fmts = cfg->formats;
             const AVFilterChannelLayouts *const layouts = cfg->channel_layouts;
 
-            for (unsigned j = 0; j < fmts->nb_formats; j++)
+            for (unsigned j = 0; fmts && j < fmts->nb_formats; j++)
                 printf("%s[%u] %s: fmt:%s\n",
                        inout_string, i, pad_name,
                        av_get_sample_fmt_name(fmts->formats[j]));
 
-            for (unsigned j = 0; j < layouts->nb_channel_layouts; j++) {
+            for (unsigned j = 0; layouts && j < layouts->nb_channel_layouts; j++) {
                 char buf[256];
                 av_get_channel_layout_string(buf, sizeof(buf), -1,
                                              layouts->channel_layouts[j]);