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-29 11:40:04 +0000
commit327c439f811a89d774db9a86f72951d295193e5f (patch)
tree677c7e245a96657e00f96613a38f868d2e4d8743 /libavdevice/timefilter.c
parente78913052263af80855590659fb0f705e8f13c8a (diff)
downloadffmpeg-327c439f811a89d774db9a86f72951d295193e5f.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.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavdevice/timefilter.c b/libavdevice/timefilter.c
index 8b98d338f0..a49735158c 100644
--- a/libavdevice/timefilter.c
+++ b/libavdevice/timefilter.c
@@ -41,7 +41,11 @@ TimeFilter *ff_timefilter_new(double clock_period,
double feedback2_factor,
double feedback3_factor)
{
- TimeFilter *self = av_mallocz(sizeof(TimeFilter));
+ TimeFilter *self = av_mallocz(sizeof(TimeFilter));
+
+ if (!self)
+ return NULL;
+
self->clock_period = clock_period;
self->feedback2_factor = feedback2_factor;
self->feedback3_factor = feedback3_factor;
@@ -105,6 +109,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 allocate memory for timefilter.\n");
+ exit(1);
+ }
for (i = 0; i < SAMPLES; i++) {
double filtered;
filtered = ff_timefilter_update(tf, samples[i], 1);