[FFmpeg-cvslog] avutil/buffer: Check ff_mutex_init() for failure

Michael Niedermayer git at videolan.org
Wed Jul 24 17:51:05 EEST 2024


ffmpeg | branch: release/4.3 | Michael Niedermayer <michael at niedermayer.cc> | Thu Jul 11 22:55:31 2024 +0200| [fcef4eb0e7bfe48954a82b6fac2aadca928a8689] | committer: Michael Niedermayer

avutil/buffer: Check ff_mutex_init() for failure

Fixes: CID1604487 Unchecked return value
Fixes: CID1604494 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 82f5b20ff5be4fccbf42f4b90f155db0076c0462)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavutil/buffer.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index 38a554208a..280fa8e108 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -223,7 +223,10 @@ AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
     if (!pool)
         return NULL;
 
-    ff_mutex_init(&pool->mutex, NULL);
+    if (ff_mutex_init(&pool->mutex, NULL)) {
+        av_free(pool);
+        return NULL;
+    }
 
     pool->size      = size;
     pool->opaque    = opaque;
@@ -242,7 +245,10 @@ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size))
     if (!pool)
         return NULL;
 
-    ff_mutex_init(&pool->mutex, NULL);
+    if (ff_mutex_init(&pool->mutex, NULL)) {
+        av_free(pool);
+        return NULL;
+    }
 
     pool->size     = size;
     pool->alloc    = alloc ? alloc : av_buffer_alloc;



More information about the ffmpeg-cvslog mailing list