summaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2011-05-03 21:25:40 -0400
committerRonald S. Bultje <rsbultje@gmail.com>2011-05-03 22:35:23 -0400
commit0699dbb8478886826dedb1c33a0b74142a1cd863 (patch)
tree96142fdff6f8262b855a04daa867f96e8d252764 /libavfilter
parentd969e93a72102a4162a1b20ec0b4fe22c69f3ff7 (diff)
downloadffmpeg-streaming-0699dbb8478886826dedb1c33a0b74142a1cd863.zip
ffmpeg-streaming-0699dbb8478886826dedb1c33a0b74142a1cd863.tar.gz
avfilter: check malloc return values.
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/avfilter.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index c71c046..82350d1 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)
OpenPOWER on IntegriCloud