aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice/timefilter.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2013-10-22 18:46:37 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2013-10-27 19:14:23 +0000
commit6ef30976e00a07ed7c6db54102d2ba50d24c876c (patch)
treeec4f00cf039688f9bb35f6e475dbc3327c32a76d /libavdevice/timefilter.c
parentfc7be7ddf3dea2f95d2d8bedde2fed44b4f469f2 (diff)
downloadffmpeg-6ef30976e00a07ed7c6db54102d2ba50d24c876c.tar.gz
timefilter: Handle memory allocation failure
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavdevice/timefilter.c')
-rw-r--r--libavdevice/timefilter.c8
1 files changed, 8 insertions, 0 deletions
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);