summaryrefslogtreecommitdiff
path: root/libswresample/dither.c
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-06-02 23:17:48 -0400
committerMichael Niedermayer <michaelni@gmx.at>2015-06-03 11:46:37 +0200
commit196b885a5f0aa3ca022c1fa99509f47341239784 (patch)
treeef9bca53a6d768bc1771ba77bfacf50fc488ab31 /libswresample/dither.c
parent7495e728f5a21bb1619789f12227dcdb1baf65ee (diff)
downloadffmpeg-196b885a5f0aa3ca022c1fa99509f47341239784.tar.gz
swresample/dither: check memory allocation
check memory allocation in swri_get_dither() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample/dither.c')
-rw-r--r--libswresample/dither.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libswresample/dither.c b/libswresample/dither.c
index ca09e67f4d..248062aab8 100644
--- a/libswresample/dither.c
+++ b/libswresample/dither.c
@@ -23,12 +23,15 @@
#include "noise_shaping_data.c"
-void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) {
+int swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) {
double scale = s->dither.noise_scale;
#define TMP_EXTRA 2
double *tmp = av_malloc_array(len + TMP_EXTRA, sizeof(double));
int i;
+ if (!tmp)
+ return AVERROR(ENOMEM);
+
for(i=0; i<len + TMP_EXTRA; i++){
double v;
seed = seed* 1664525 + 1013904223;
@@ -70,6 +73,7 @@ void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSa
}
av_free(tmp);
+ return 0;
}
av_cold int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt)