From 0994e142132200c706f704271b5a7ae81d128f5c Mon Sep 17 00:00:00 2001
From: Vittorio Giovara <vittorio.giovara@gmail.com>
Date: Sun, 31 May 2015 14:55:06 +0200
Subject: [PATCH] pthread: Check memory allocation

---
 libavcodec/pthread_frame.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index effc9a5ac3e..d7f742ba7d2 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -584,8 +584,15 @@ int ff_frame_thread_init(AVCodecContext *avctx)
     }
 
     avctx->internal->thread_ctx = fctx = av_mallocz(sizeof(FrameThreadContext));
+    if (!fctx)
+        return AVERROR(ENOMEM);
 
     fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count);
+    if (!fctx->threads) {
+        av_freep(&avctx->internal->thread_ctx);
+        return AVERROR(ENOMEM);
+    }
+
     pthread_mutex_init(&fctx->buffer_mutex, NULL);
     fctx->delaying = 1;
 
-- 
GitLab