When merging the formats around the automatically inserted convert filters, the refcount of the format lists can not be 0. Coverity does not detect it, and suspects a memory leak, because if refcount is 0 the newly allocated lists are not stored anywhere. That gives CIDs 1224282, 1224283 and 1224284. Lists with refcount 0 are used in can_merge_formats(), so the asserts can not be moved inside the merge functions.
Unified · Split
| @@ -562,6 +562,20 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 561 unmodified lines | ||
| 562 | 562 | filter_query_formats(convert); |
| 563 | 563 | inlink = convert->inputs[0]; |
| 564 | 564 | outlink = convert->outputs[0]; |
| 565 | + av_assert0( inlink-> in_formats->refcount > 0); | |
| 566 | + av_assert0( inlink->out_formats->refcount > 0); | |
| 567 | + av_assert0(outlink-> in_formats->refcount > 0); | |
| 568 | + av_assert0(outlink->out_formats->refcount > 0); | |
| 569 | + if (outlink->type == AVMEDIA_TYPE_AUDIO) { | |
| 570 | + av_assert0( inlink-> in_samplerates->refcount > 0); | |
| 571 | + av_assert0( inlink->out_samplerates->refcount > 0); | |
| 572 | + av_assert0(outlink-> in_samplerates->refcount > 0); | |
| 573 | + av_assert0(outlink->out_samplerates->refcount > 0); | |
| 574 | + av_assert0( inlink-> in_channel_layouts->refcount > 0); | |
| 575 | + av_assert0( inlink->out_channel_layouts->refcount > 0); | |
| 576 | + av_assert0(outlink-> in_channel_layouts->refcount > 0); | |
| 577 | + av_assert0(outlink->out_channel_layouts->refcount > 0); | |
| 578 | + } | |
| 565 | 579 | if (!ff_merge_formats( inlink->in_formats, inlink->out_formats, inlink->type) || |
| 566 | 580 | !ff_merge_formats(outlink->in_formats, outlink->out_formats, outlink->type)) |
| 567 | 581 | ret = AVERROR(ENOSYS); |