diff options
author | Jiasheng Jiang <jiasheng@iscas.ac.cn> | 2022-02-23 10:31:59 +0800 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2022-02-23 14:13:16 +0100 |
commit | 9cf652cef49d74afe3d454f27d49eb1a1394951e (patch) | |
tree | 3e1641fd1ad571d35682fdf7f75219f178c0f20c /libavformat/nutdec.c | |
parent | b14321e307fcd662f8d9aaa17c7f297cba2cbe4a (diff) | |
download | ffmpeg-9cf652cef49d74afe3d454f27d49eb1a1394951e.tar.gz |
avformat/nutdec: Add check for avformat_new_stream
Check for failure of avformat_new_stream() and propagate
the error code.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/nutdec.c')
-rw-r--r-- | libavformat/nutdec.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 0a8a700acf..f9ad2c0af1 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -351,8 +351,12 @@ static int decode_main_header(NUTContext *nut) ret = AVERROR(ENOMEM); goto fail; } - for (i = 0; i < stream_count; i++) - avformat_new_stream(s, NULL); + for (i = 0; i < stream_count; i++) { + if (!avformat_new_stream(s, NULL)) { + ret = AVERROR(ENOMEM); + goto fail; + } + } return 0; fail: @@ -800,19 +804,23 @@ static int nut_read_header(AVFormatContext *s) NUTContext *nut = s->priv_data; AVIOContext *bc = s->pb; int64_t pos; - int initialized_stream_count; + int initialized_stream_count, ret; nut->avf = s; /* main header */ pos = 0; + ret = 0; do { + if (ret == AVERROR(ENOMEM)) + return ret; + pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1; if (pos < 0 + 1) { av_log(s, AV_LOG_ERROR, "No main startcode found.\n"); return AVERROR_INVALIDDATA; } - } while (decode_main_header(nut) < 0); + } while ((ret = decode_main_header(nut)) < 0); /* stream headers */ pos = 0; |