aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pthread_slice.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-07-31 12:55:41 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-31 12:56:21 +0200
commit72555f4a382744dd7f02edcb7fe6f8ed91f4dc3c (patch)
tree75dc62fd86f8251c69c8b9a2a42a3238ec7c3bbf /libavcodec/pthread_slice.c
parent37ec7d291eacedfacdce21332f4c719f2be79d12 (diff)
downloadffmpeg-72555f4a382744dd7f02edcb7fe6f8ed91f4dc3c.tar.gz
avcodec/pthread_slice: Check for malloc failure
Found-by: CSA Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pthread_slice.c')
-rw-r--r--libavcodec/pthread_slice.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index 334aaac0fc..fea989fc4c 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -268,13 +268,16 @@ int ff_alloc_entries(AVCodecContext *avctx, int count)
p->thread_count = avctx->thread_count;
p->entries = av_mallocz_array(count, sizeof(int));
- if (!p->entries) {
+ p->progress_mutex = av_malloc_array(p->thread_count, sizeof(pthread_mutex_t));
+ p->progress_cond = av_malloc_array(p->thread_count, sizeof(pthread_cond_t));
+
+ if (!p->entries || !p->progress_mutex || !p->progress_cond) {
+ av_freep(&p->entries);
+ av_freep(&p->progress_mutex);
+ av_freep(&p->progress_cond);
return AVERROR(ENOMEM);
}
-
p->entries_count = count;
- p->progress_mutex = av_malloc_array(p->thread_count, sizeof(pthread_mutex_t));
- p->progress_cond = av_malloc_array(p->thread_count, sizeof(pthread_cond_t));
for (i = 0; i < p->thread_count; i++) {
pthread_mutex_init(&p->progress_mutex[i], NULL);