ff_add_format() and ff_add_channel_layout() already unref the list upon error.
Showing the changes to libavfilter (3 of 3 files). Show all
Unified · Split
| @@ -60,7 +60,7 @@ static const AVOption aformat_options[] = { · 59 unmodified lines | ||
| 60 | 60 | |
| 61 | 61 | AVFILTER_DEFINE_CLASS(aformat); |
| 62 | 62 | |
| 63 | −#define PARSE_FORMATS(str, type, list, add_to_list, unref_fn, get_fmt, none, desc) \ | |
| 63 | +#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \ | |
| 64 | 64 | do { \ |
| 65 | 65 | char *next, *cur = str, sep; \ |
| 66 | 66 | int ret; \ |
| @@ -83,7 +83,6 @@ do { \ · 16 unmodified lines | ||
| 83 | 83 | return AVERROR(EINVAL); \ |
| 84 | 84 | } \ |
| 85 | 85 | if ((ret = add_to_list(&list, fmt)) < 0) { \ |
| 86 | − unref_fn(&list); \ | |
| 87 | 86 | return ret; \ |
| 88 | 87 | } \ |
| 89 | 88 | \ |
| @@ -102,11 +101,11 @@ static av_cold int init(AVFilterContext *ctx) · 12 unmodified lines | ||
| 102 | 101 | AFormatContext *s = ctx->priv; |
| 103 | 102 | |
| 104 | 103 | PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats, |
| 105 | − ff_add_format, ff_formats_unref, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); | |
| 106 | − PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, ff_formats_unref, | |
| 104 | + ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); | |
| 105 | + PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, | |
| 107 | 106 | get_sample_rate, 0, "sample rate"); |
| 108 | 107 | PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts, |
| 109 | − ff_add_channel_layout, ff_channel_layouts_unref, av_get_channel_layout, 0, | |
| 108 | + ff_add_channel_layout, av_get_channel_layout, 0, | |
| 110 | 109 | "channel layout"); |
| 111 | 110 | |
| 112 | 111 | return 0; |
| @@ -64,7 +64,6 @@ static int query_formats(AVFilterContext *ctx) · 63 unmodified lines | ||
| 64 | 64 | if (i != 4) |
| 65 | 65 | continue; |
| 66 | 66 | if ((ret = ff_add_format(&formats, fmt)) < 0) { |
| 67 | − ff_formats_unref(&formats); | |
| 68 | 67 | return ret; |
| 69 | 68 | } |
| 70 | 69 | } |
| @@ -60,7 +60,6 @@ static int query_formats(AVFilterContext *ctx) · 59 unmodified lines | ||
| 60 | 60 | if (!(desc->flags & AV_PIX_FMT_FLAG_PAL) && |
| 61 | 61 | !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { |
| 62 | 62 | if ((ret = ff_add_format(&formats, fmt)) < 0) { |
| 63 | − ff_formats_unref(&formats); | |
| 64 | 63 | return ret; |
| 65 | 64 | } |
| 66 | 65 | } |