]> git.sesse.net Git - ffmpeg/commitdiff
pthread: Check memory allocation
authorVittorio Giovara <vittorio.giovara@gmail.com>
Sun, 31 May 2015 12:55:06 +0000 (14:55 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Sun, 31 May 2015 13:03:31 +0000 (15:03 +0200)
libavcodec/pthread_frame.c

index effc9a5ac3e518fa4f2ee7beb2839332ab96bd98..d7f742ba7d2e9ee4f84ea1fa0bb8c07aedaf80c0 100644 (file)
@@ -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;