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.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -742,14 +742,14 @@ static int query_formats(AVFilterContext *ctx) · 741 unmodified lines | |||
| 742 | } else { | 742 | } else { |
| 743 | AVFilterChannelLayouts *mono = NULL; | 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 | if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->out_channel_layouts)) < 0) | 745 | if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->out_channel_layouts)) < 0) |
| 750 | return ret; | 746 | return ret; |
| 751 | if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts)) < 0) | 747 | if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts)) < 0) |
| 752 | return ret; | 748 | return ret; |
| 749 | |||
| 750 | ret = ff_add_channel_layout(&mono, AV_CH_LAYOUT_MONO); | ||
| 751 | if (ret) | ||
| 752 | return ret; | ||
| 753 | for (int i = 1; i < ctx->nb_inputs; i++) { | 753 | for (int i = 1; i < ctx->nb_inputs; i++) { |
| 754 | if ((ret = ff_channel_layouts_ref(mono, &ctx->inputs[i]->out_channel_layouts)) < 0) | 754 | if ((ret = ff_channel_layouts_ref(mono, &ctx->inputs[i]->out_channel_layouts)) < 0) |
| 755 | return ret; | 755 | return ret; |