diff options
author | Ronald S. Bultje | 2011-05-03 21:25:40 -0400 |
---|---|---|
committer | Ronald S. Bultje | 2011-05-03 22:35:23 -0400 |
commit | 0699dbb8478886826dedb1c33a0b74142a1cd863 (patch) | |
tree | 96142fdff6f8262b855a04daa867f96e8d252764 | |
parent | d969e93a72102a4162a1b20ec0b4fe22c69f3ff7 (diff) |
avfilter: check malloc return values.
-rw-r--r-- | libavfilter/avfilter.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index c71c046c53..82350d1790 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -583,29 +583,53 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in return AVERROR(EINVAL); ret = av_mallocz(sizeof(AVFilterContext)); + if (!ret) + return AVERROR(ENOMEM); ret->av_class = &avfilter_class; ret->filter = filter; ret->name = inst_name ? av_strdup(inst_name) : NULL; - if (filter->priv_size) + if (filter->priv_size) { ret->priv = av_mallocz(filter->priv_size); + if (!ret->priv) + goto err; + } ret->input_count = pad_count(filter->inputs); if (ret->input_count) { ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count); + if (!ret->input_pads) + goto err; memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->input_count); ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count); + if (!ret->inputs) + goto err; } ret->output_count = pad_count(filter->outputs); if (ret->output_count) { ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count); + if (!ret->output_pads) + goto err; memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->output_count); ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count); + if (!ret->outputs) + goto err; } *filter_ctx = ret; return 0; + +err: + av_freep(&ret->inputs); + av_freep(&ret->input_pads); + ret->input_count = 0; + av_freep(&ret->outputs); + av_freep(&ret->output_pads); + ret->output_count = 0; + av_freep(&ret->priv); + av_free(ret); + return AVERROR(ENOMEM); } void avfilter_free(AVFilterContext *filter) |