[FFmpeg-cvslog] avcodec/pthread_slice: Check for malloc failure

Michael Niedermayer git at videolan.org
Thu Jul 31 13:04:10 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Jul 31 12:55:41 2014 +0200| [72555f4a382744dd7f02edcb7fe6f8ed91f4dc3c] | committer: Michael Niedermayer

avcodec/pthread_slice: Check for malloc failure

Found-by: CSA
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72555f4a382744dd7f02edcb7fe6f8ed91f4dc3c
---

 libavcodec/pthread_slice.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index 334aaac..fea989f 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);



More information about the ffmpeg-cvslog mailing list