[FFmpeg-devel] [PATCH 2/2] avutil/buffer: reject NULL as argument for the av_buffer_pool_init2() alloc callback
James Almer
jamrial at gmail.com
Sun May 31 02:32:04 EEST 2020
This prevents NULL pointer dereference crashes when calling av_buffer_pool_get()
using the resulting pool.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavutil/buffer.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index 6d9cb7428e..6fe8f19c39 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -220,7 +220,11 @@ AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
AVBufferRef* (*alloc)(void *opaque, int size),
void (*pool_free)(void *opaque))
{
- AVBufferPool *pool = av_mallocz(sizeof(*pool));
+ AVBufferPool *pool;
+
+ if (!alloc)
+ return NULL;
+ pool = av_mallocz(sizeof(*pool));
if (!pool)
return NULL;
--
2.26.2
More information about the ffmpeg-devel
mailing list