diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-01-20 18:28:16 +0000 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2011-01-20 18:35:13 +0000 |
commit | d42dc217ed2b0f886ffc50b26c2bbff1fee5feca (patch) | |
tree | 79358252cbf0585640e462475ff9509e2f7fd625 /libavcodec/iirfilter.c | |
parent | f0f54c297f1283025d423c4aed817ae31ba549cb (diff) | |
download | ffmpeg-d42dc217ed2b0f886ffc50b26c2bbff1fee5feca.tar.gz |
Add memory allocation failure checks to ff_iir_filter_init_coeffs().
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/iirfilter.c')
-rw-r--r-- | libavcodec/iirfilter.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c index 60313f1abe..afa299f64f 100644 --- a/libavcodec/iirfilter.c +++ b/libavcodec/iirfilter.c @@ -47,7 +47,8 @@ typedef struct FFIIRFilterState{ /// maximum supported filter order #define MAXORDER 30 -av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type, +av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc, + enum IIRFilterType filt_type, enum IIRFilterMode filt_mode, int order, float cutoff_ratio, float stopband, float ripple) @@ -62,9 +63,12 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType f if(order <= 1 || (order & 1) || order > MAXORDER || cutoff_ratio >= 1.0) return NULL; - c = av_malloc(sizeof(FFIIRFilterCoeffs)); - c->cx = av_malloc(sizeof(c->cx[0]) * ((order >> 1) + 1)); - c->cy = av_malloc(sizeof(c->cy[0]) * order); + FF_ALLOCZ_OR_GOTO(avc, c, sizeof(FFIIRFilterCoeffs), + init_fail); + FF_ALLOC_OR_GOTO (avc, c->cx, sizeof(c->cx[0]) * ((order >> 1) + 1), + init_fail); + FF_ALLOC_OR_GOTO (avc, c->cy, sizeof(c->cy[0]) * order, + init_fail); c->order = order; wa = 2 * tan(M_PI * 0.5 * cutoff_ratio); @@ -110,6 +114,10 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType f c->gain /= 1 << order; return c; + +init_fail: + ff_iir_filter_free_coeffs(c); + return NULL; } av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order) |