[FFmpeg-cvslog] pthread: Check memory allocation

Vittorio Giovara git at videolan.org
Mon Jun 1 02:34:41 CEST 2015


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Sun May 31 14:55:06 2015 +0200| [0994e142132200c706f704271b5a7ae81d128f5c] | committer: Luca Barbato

pthread: Check memory allocation

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

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

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index effc9a5..d7f742b 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;
 



More information about the ffmpeg-cvslog mailing list