summaryrefslogtreecommitdiff
path: root/libavfilter/avfilter.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-05 03:09:48 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-05 03:30:24 +0200
commitb000b86e1dd03c4ff89cd63a6fa88fc280947c94 (patch)
tree8ba961dc8c013885d7bdfe944fb7cb31d5dc6d95 /libavfilter/avfilter.c
parent9a5624a0f1b205e966391645a512c6dccdce42cd (diff)
parentaf1ca249e8eb685823dd0dade3aa3c1d119a61ec (diff)
Merge remote branch 'qatar/master'
* qatar/master: (23 commits) doc: Check standalone compilation before submitting new components. Fix standalone compilation of pipe protocol. Fix standalone compilation of ac3_fixed encoder. Fix standalone compilation of binkaudio_dct / binkaudio_rdft decoders. Fix standalone compilation of IMC decoder. Fix standalone compilation of WTV demuxer. Fix standalone compilation of MXPEG decoder. flashsv: K&R cosmetics matroskaenc: fix memory leak vc1: make overlap filter for I-frames bit-exact. vc1dec: use s->start/end_mb_y instead of passing them as function args. Revert "VC1: merge idct8x8, coeff adjustments and put_pixels." Replace strncpy() with av_strlcpy(). indeo3: Eliminate use of long. get_bits: make cache unsigned to eliminate undefined signed overflow. asfdec: fix assert failure on invalid files avfilter: check malloc return values. Not pulled as reason for reindent is not pulled: mpegvideo: reindent. nutenc: check malloc return values. Not pulled due to much simpler solution in ffmpeg *: don't av_malloc(0). ... Conflicts: doc/developer.texi libavcodec/Makefile libavcodec/get_bits.h libavcodec/mpegvideo.c libavformat/Makefile libavutil/log.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r--libavfilter/avfilter.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 49d84e08b8..f784cbff8c 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -585,28 +585,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;
- ret->priv = av_mallocz(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)