If an error happens between the allocation of an AVFilterChannelLayout and its usage (which involves attaching said object to a more permanent object), the channel layout array leaks. This can simply be fixed by making sure that nothing is between the allocation and the aforementioned usage. Fixes Coverity issue #1250334.
Unified · Split
| @@ -742,14 +742,14 @@ static int query_formats(AVFilterContext *ctx) · 741 unmodified lines | ||
| 742 | 742 | } else { |
| 743 | 743 | AVFilterChannelLayouts *mono = NULL; |
| 744 | 744 | |
| 745 | − ret = ff_add_channel_layout(&mono, AV_CH_LAYOUT_MONO); | |
| 746 | − if (ret) | |
| 747 | − return ret; | |
| 748 | − | |
| 749 | 745 | if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->out_channel_layouts)) < 0) |
| 750 | 746 | return ret; |
| 751 | 747 | if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts)) < 0) |
| 752 | 748 | return ret; |
| 749 | + | |
| 750 | + ret = ff_add_channel_layout(&mono, AV_CH_LAYOUT_MONO); | |
| 751 | + if (ret) | |
| 752 | + return ret; | |
| 753 | 753 | for (int i = 1; i < ctx->nb_inputs; i++) { |
| 754 | 754 | if ((ret = ff_channel_layouts_ref(mono, &ctx->inputs[i]->out_channel_layouts)) < 0) |
| 755 | 755 | return ret; |