From 9887ec3e9bf81ad7680539d9361187dc4bcd2fb3 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Fri, 28 Jan 2022 10:08:18 +0800 Subject: [PATCH] avutil/tx: add null pointer check after av_mallocz Fix CID: 1497863 there will get null pointer in attempt to initialize each if alloc memory failed. Signed-off-by: Steven Liu --- libavutil/tx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavutil/tx.c b/libavutil/tx.c index 50616adba7..06e8958283 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -565,8 +565,13 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type, print_cd_info(cd_matches[i].cd, cd_matches[i].prio, 1); } - if (!s->sub) + if (!s->sub) { s->sub = sub = av_mallocz(TX_MAX_SUB*sizeof(*sub)); + if (!sub) { + ret = AVERROR(ENOMEM); + goto end; + } + } /* Attempt to initialize each */ for (int i = 0; i < nb_cd_matches; i++) {