From 6ef30976e00a07ed7c6db54102d2ba50d24c876c Mon Sep 17 00:00:00 2001 From: Derek Buitenhuis Date: Tue, 22 Oct 2013 18:46:37 +0100 Subject: timefilter: Handle memory allocation failure Signed-off-by: Derek Buitenhuis --- libavdevice/timefilter.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libavdevice/timefilter.c') diff --git a/libavdevice/timefilter.c b/libavdevice/timefilter.c index 424e4929bd..b4133e085c 100644 --- a/libavdevice/timefilter.c +++ b/libavdevice/timefilter.c @@ -49,6 +49,10 @@ TimeFilter *ff_timefilter_new(double time_base, { TimeFilter *self = av_mallocz(sizeof(TimeFilter)); double o = 2 * M_PI * bandwidth * period * time_base; + + if (!self) + return NULL; + self->clock_period = time_base; self->feedback2_factor = qexpneg(M_SQRT2 * o); self->feedback3_factor = qexpneg(o * o) / period; @@ -121,6 +125,10 @@ int main(void) for (par1 = bestpar1 * 0.8; par1 <= bestpar1 * 1.21; par1 += bestpar1 * 0.05) { double error = 0; TimeFilter *tf = ff_timefilter_new(1, par0, par1); + if (!tf) { + printf("Could not alocate memory for timefilter.\n"); + exit(1); + } for (i = 0; i < SAMPLES; i++) { double filtered; filtered = ff_timefilter_update(tf, samples[i], i ? (samplet[i] - samplet[i-1]) : 1); -- cgit v1.2.3