diff mbox series

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

Message ID 20220128020818.39850-2-lq@chinaffmpeg.org
State New
Headers show
Series [FFmpeg-devel,1/2] avutil/tx: remove deadcode of the control flow | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Liu Steven Jan. 28, 2022, 2:08 a.m. UTC
From: Steven Liu <liuqi05@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@kuaishou.com>
---
 libavutil/tx.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

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++) {