aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2009-01-12 20:30:57 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2009-01-12 20:30:57 +0000
commit689a5f493b62574b6e36cb1fd14d067b81847713 (patch)
tree25adc8d270171b7226569e32e28af33e195d0e68 /libavfilter
parent7b114c0925f1b22a5f73c5b6d68fb7369352fec8 (diff)
downloadffmpeg-689a5f493b62574b6e36cb1fd14d067b81847713.tar.gz
Make avfilter_open() set to NULL the pads and the filters when the
corresponding count is zero, rather than allocate a 16 bytes sized block for them. Improve safety. Originally committed as revision 16565 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/avfilter.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 283fd0aa4a..ae424c4735 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -341,7 +341,7 @@ AVFilterContext *avfilter_open(AVFilter *filter, const char *inst_name)
if (!filter)
return 0;
- ret = av_malloc(sizeof(AVFilterContext));
+ ret = av_mallocz(sizeof(AVFilterContext));
ret->av_class = &avfilter_class;
ret->filter = filter;
@@ -349,14 +349,18 @@ AVFilterContext *avfilter_open(AVFilter *filter, const char *inst_name)
ret->priv = av_mallocz(filter->priv_size);
ret->input_count = pad_count(filter->inputs);
+ if (ret->input_count) {
ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);
memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad)*ret->input_count);
ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);
+ }
ret->output_count = pad_count(filter->outputs);
+ if (ret->output_count) {
ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);
memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad)*ret->output_count);
ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);
+ }
return ret;
}