History

avfilter/tests/filtfmts: Check for existence of formats/channel layouts

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.

Andreas Rheinhardt committed 5 years ago

Commit 9a1547b1 parent a228bae1 file · +3 −3Browse files

Unified · Split

libavfilter/tests/filtfmts.c+3−3
@@ -43,7 +43,7 @@ static void print_formats_internal(AVFilterLink **links, const AVFilterPad *pads · 42 unmodified lines
4343
4444 if (link->type == AVMEDIA_TYPE_VIDEO) {
4545 const AVFilterFormats *const fmts = cfg->formats;
46− for (unsigned j = 0; j < fmts->nb_formats; j++) {
46+ for (unsigned j = 0; fmts && j < fmts->nb_formats; j++) {
4747 printf("%s[%u] %s: fmt:%s\n",
4848 inout_string, i, pad_name,
4949 av_get_pix_fmt_name(fmts->formats[j]));
@@ -52,12 +52,12 @@ static void print_formats_internal(AVFilterLink **links, const AVFilterPad *pads · 2 unmodified lines
5252 const AVFilterFormats *const fmts = cfg->formats;
5353 const AVFilterChannelLayouts *const layouts = cfg->channel_layouts;
5454
55− for (unsigned j = 0; j < fmts->nb_formats; j++)
55+ for (unsigned j = 0; fmts && j < fmts->nb_formats; j++)
5656 printf("%s[%u] %s: fmt:%s\n",
5757 inout_string, i, pad_name,
5858 av_get_sample_fmt_name(fmts->formats[j]));
5959
60− for (unsigned j = 0; j < layouts->nb_channel_layouts; j++) {
60+ for (unsigned j = 0; layouts && j < layouts->nb_channel_layouts; j++) {
6161 char buf[256];
6262 av_get_channel_layout_string(buf, sizeof(buf), -1,
6363 layouts->channel_layouts[j]);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t