summaryrefslogtreecommitdiff
path: root/libavcodec/resample.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-07-31 13:04:28 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-31 13:04:28 +0200
commitceff29b9ad611ae5c357a068eee047912bb9e8ff (patch)
tree1710145cf9ca0c24be679dbdaba529200ee2205c /libavcodec/resample.c
parent72555f4a382744dd7f02edcb7fe6f8ed91f4dc3c (diff)
avcodec/resample: check for malloc failure
Found-by: CSA Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/resample.c')
-rw-r--r--libavcodec/resample.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/resample.c b/libavcodec/resample.c
index 7c0f828be2..c45aa16cd1 100644
--- a/libavcodec/resample.c
+++ b/libavcodec/resample.c
@@ -348,9 +348,16 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
/* XXX: move those malloc to resample init code */
for (i = 0; i < s->filter_channels; i++) {
bufin[i] = av_malloc_array((nb_samples + s->temp_len), sizeof(short));
+ bufout[i] = av_malloc_array(lenout, sizeof(short));
+
+ if (!bufin[i] || !bufout[i]) {
+ av_log(s->resample_context, AV_LOG_ERROR, "Could not allocate buffer\n");
+ nb_samples1 = 0;
+ goto fail;
+ }
+
memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short));
buftmp2[i] = bufin[i] + s->temp_len;
- bufout[i] = av_malloc_array(lenout, sizeof(short));
}
if (s->input_channels == 2 && s->output_channels == 1) {
@@ -411,6 +418,7 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
}
}
+fail:
for (i = 0; i < s->filter_channels; i++) {
av_free(bufin[i]);
av_free(bufout[i]);