mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-12 02:04:58 +00:00
lavfi/buffersink: fix possible leaks after allocation failures.
Should fix Coverity CID 1005313, 1005314, 1005315.
This commit is contained in:
parent
b57c23f8c8
commit
fd7a7e11b9
@ -401,8 +401,10 @@ static int vsink_query_formats(AVFilterContext *ctx)
|
|||||||
CHECK_LIST_SIZE(pixel_fmts)
|
CHECK_LIST_SIZE(pixel_fmts)
|
||||||
if (buf->pixel_fmts_size) {
|
if (buf->pixel_fmts_size) {
|
||||||
for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)
|
for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)
|
||||||
if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0)
|
if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0) {
|
||||||
|
ff_formats_unref(&formats);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
ff_set_common_formats(ctx, formats);
|
ff_set_common_formats(ctx, formats);
|
||||||
} else {
|
} else {
|
||||||
ff_default_query_formats(ctx);
|
ff_default_query_formats(ctx);
|
||||||
@ -443,19 +445,25 @@ static int asink_query_formats(AVFilterContext *ctx)
|
|||||||
|
|
||||||
if (buf->sample_fmts_size) {
|
if (buf->sample_fmts_size) {
|
||||||
for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++)
|
for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++)
|
||||||
if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0)
|
if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0) {
|
||||||
|
ff_formats_unref(&formats);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
ff_set_common_formats(ctx, formats);
|
ff_set_common_formats(ctx, formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf->channel_layouts_size || buf->channel_counts_size ||
|
if (buf->channel_layouts_size || buf->channel_counts_size ||
|
||||||
buf->all_channel_counts) {
|
buf->all_channel_counts) {
|
||||||
for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
|
for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
|
||||||
if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0)
|
if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0) {
|
||||||
|
ff_channel_layouts_unref(&layouts);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
for (i = 0; i < NB_ITEMS(buf->channel_counts); i++)
|
for (i = 0; i < NB_ITEMS(buf->channel_counts); i++)
|
||||||
if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0)
|
if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0) {
|
||||||
|
ff_channel_layouts_unref(&layouts);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
if (buf->all_channel_counts) {
|
if (buf->all_channel_counts) {
|
||||||
if (layouts)
|
if (layouts)
|
||||||
av_log(ctx, AV_LOG_WARNING,
|
av_log(ctx, AV_LOG_WARNING,
|
||||||
@ -469,8 +477,10 @@ static int asink_query_formats(AVFilterContext *ctx)
|
|||||||
if (buf->sample_rates_size) {
|
if (buf->sample_rates_size) {
|
||||||
formats = NULL;
|
formats = NULL;
|
||||||
for (i = 0; i < NB_ITEMS(buf->sample_rates); i++)
|
for (i = 0; i < NB_ITEMS(buf->sample_rates); i++)
|
||||||
if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0)
|
if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0) {
|
||||||
|
ff_formats_unref(&formats);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
ff_set_common_samplerates(ctx, formats);
|
ff_set_common_samplerates(ctx, formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user