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.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -43,7 +43,7 @@ static void print_formats_internal(AVFilterLink **links, const AVFilterPad *pads · 42 unmodified lines | |||
| 43 | 43 | ||
| 44 | if (link->type == AVMEDIA_TYPE_VIDEO) { | 44 | if (link->type == AVMEDIA_TYPE_VIDEO) { |
| 45 | const AVFilterFormats *const fmts = cfg->formats; | 45 | 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++) { |
| 47 | printf("%s[%u] %s: fmt:%s\n", | 47 | printf("%s[%u] %s: fmt:%s\n", |
| 48 | inout_string, i, pad_name, | 48 | inout_string, i, pad_name, |
| 49 | av_get_pix_fmt_name(fmts->formats[j])); | 49 | 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 | |||
| 52 | const AVFilterFormats *const fmts = cfg->formats; | 52 | const AVFilterFormats *const fmts = cfg->formats; |
| 53 | const AVFilterChannelLayouts *const layouts = cfg->channel_layouts; | 53 | const AVFilterChannelLayouts *const layouts = cfg->channel_layouts; |
| 54 | 54 | ||
| 55 | for (unsigned j = 0; j < fmts->nb_formats; j++) | 55 | for (unsigned j = 0; fmts && j < fmts->nb_formats; j++) |
| 56 | printf("%s[%u] %s: fmt:%s\n", | 56 | printf("%s[%u] %s: fmt:%s\n", |
| 57 | inout_string, i, pad_name, | 57 | inout_string, i, pad_name, |
| 58 | av_get_sample_fmt_name(fmts->formats[j])); | 58 | av_get_sample_fmt_name(fmts->formats[j])); |
| 59 | 59 | ||
| 60 | for (unsigned j = 0; j < layouts->nb_channel_layouts; j++) { | 60 | for (unsigned j = 0; layouts && j < layouts->nb_channel_layouts; j++) { |
| 61 | char buf[256]; | 61 | char buf[256]; |
| 62 | av_get_channel_layout_string(buf, sizeof(buf), -1, | 62 | av_get_channel_layout_string(buf, sizeof(buf), -1, |
| 63 | layouts->channel_layouts[j]); | 63 | layouts->channel_layouts[j]); |