[FFmpeg-devel] [PATCH 2/2] avutil/tx: add null pointer check after av_mallocz

Steven Liu lq at chinaffmpeg.org
Fri Jan 28 04:08:18 EET 2022


From: Steven Liu <liuqi05 at kuaishou.com>

Fix CID: 1497863
there will get null pointer in attempt to initialize each if alloc memory failed.

Signed-off-by: Steven Liu <liuqi05 at kuaishou.com>
---
 libavutil/tx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavutil/tx.c b/libavutil/tx.c
index 50616adba7..79c9477d7f 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -567,6 +567,10 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type,
 
     if (!s->sub)
         s->sub = sub = av_mallocz(TX_MAX_SUB*sizeof(*sub));
+    if (!s->sub) {
+        ret = AVERROR(ENOMEM);
+        goto end;
+    }
 
     /* Attempt to initialize each */
     for (int i = 0; i < nb_cd_matches; i++) {
-- 
2.25.0



More information about the ffmpeg-devel mailing list