diff options
author | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-10-04 23:39:25 -0400 |
---|---|---|
committer | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-10-14 10:04:01 -0400 |
commit | 6aaac24d72a7da631173209841a3944fcb4a3309 (patch) | |
tree | 4b475e1648073cd36acad767e54486722ac3c15f /libavfilter/avfiltergraph.c | |
parent | 8ededd583622359062622cf008144a1511d50bbd (diff) | |
download | ffmpeg-6aaac24d72a7da631173209841a3944fcb4a3309.tar.gz |
avfilter/all: propagate errors of functions from avfilter/formats
Many of the functions from avfilter/formats can return errors, usually AVERROR(ENOMEM).
This propagates the return values.
All of these were found by using av_warn_unused_result, demonstrating its utility.
Tested with FATE. I am least sure of the changes to avfilter/filtergraph,
since I don't know what/how reduce_format is intended to behave and how it should
react to errors.
Fixes: CID 1325680, 1325679, 1325678.
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Previous version Reviewed-by: Nicolas George <george@nsup.org>
Previous version Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavfilter/avfiltergraph.c')
-rw-r--r-- | libavfilter/avfiltergraph.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index b42983140a..bc10665c3f 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -317,18 +317,15 @@ static int filter_query_formats(AVFilterContext *ctx) sanitize_channel_layouts(ctx, ctx->outputs[i]->in_channel_layouts); formats = ff_all_formats(type); - if (!formats) - return AVERROR(ENOMEM); - ff_set_common_formats(ctx, formats); + if ((ret = ff_set_common_formats(ctx, formats)) < 0) + return ret; if (type == AVMEDIA_TYPE_AUDIO) { samplerates = ff_all_samplerates(); - if (!samplerates) - return AVERROR(ENOMEM); - ff_set_common_samplerates(ctx, samplerates); + if ((ret = ff_set_common_samplerates(ctx, samplerates)) < 0) + return ret; chlayouts = ff_all_channel_layouts(); - if (!chlayouts) - return AVERROR(ENOMEM); - ff_set_common_channel_layouts(ctx, chlayouts); + if ((ret = ff_set_common_channel_layouts(ctx, chlayouts)) < 0) + return ret; } return 0; } @@ -728,7 +725,7 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) return 0; } -#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \ +#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format, unref_format) \ do { \ for (i = 0; i < filter->nb_inputs; i++) { \ AVFilterLink *link = filter->inputs[i]; \ @@ -769,9 +766,9 @@ static int reduce_formats_on_filter(AVFilterContext *filter) int i, j, k, ret = 0; REDUCE_FORMATS(int, AVFilterFormats, formats, formats, - nb_formats, ff_add_format); + nb_formats, ff_add_format, ff_formats_unref); REDUCE_FORMATS(int, AVFilterFormats, samplerates, formats, - nb_formats, ff_add_format); + nb_formats, ff_add_format, ff_formats_unref); /* reduce channel layouts */ for (i = 0; i < filter->nb_inputs; i++) { @@ -795,7 +792,8 @@ static int reduce_formats_on_filter(AVFilterContext *filter) (!FF_LAYOUT2COUNT(fmt) || fmts->all_counts)) { /* Turn the infinite list into a singleton */ fmts->all_layouts = fmts->all_counts = 0; - ff_add_channel_layout(&outlink->in_channel_layouts, fmt); + if (ff_add_channel_layout(&outlink->in_channel_layouts, fmt) < 0) + ret = 1; break; } |