[FFmpeg-devel] [PATCH] avformat/nutdec: Add check for avformat_new_stream
Jiasheng Jiang
jiasheng at iscas.ac.cn
Wed Feb 16 09:05:06 EET 2022
As the potential failure of the memory allocation,
the avformat_new_stream() could return NULL pointer.
Therefore, it should be better to check it and return
error if fails.
Fixes: 84ad31ff18 ("lavf: replace av_new_stream->avformat_new_stream part II.")
Signed-off-by: Jiasheng Jiang <jiasheng at iscas.ac.cn>
---
libavformat/nutdec.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 0a8a700acf..eb2ba4840a 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -352,7 +352,11 @@ static int decode_main_header(NUTContext *nut)
goto fail;
}
for (i = 0; i < stream_count; i++)
- avformat_new_stream(s, NULL);
+ if (!avformat_new_stream(s, NULL)) {
+ av_free(nut->stream);
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
return 0;
fail:
--
2.25.1
More information about the ffmpeg-devel
mailing list