1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-15 14:13:16 +02:00

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>
This commit is contained in:
Jiasheng Jiang
2022-02-23 10:31:59 +08:00
committed by Michael Niedermayer
parent b14321e307
commit 9cf652cef4

View File

@@ -351,8 +351,12 @@ static int decode_main_header(NUTContext *nut)
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto fail; goto fail;
} }
for (i = 0; i < stream_count; i++) for (i = 0; i < stream_count; i++) {
avformat_new_stream(s, NULL); if (!avformat_new_stream(s, NULL)) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
return 0; return 0;
fail: fail:
@@ -800,19 +804,23 @@ static int nut_read_header(AVFormatContext *s)
NUTContext *nut = s->priv_data; NUTContext *nut = s->priv_data;
AVIOContext *bc = s->pb; AVIOContext *bc = s->pb;
int64_t pos; int64_t pos;
int initialized_stream_count; int initialized_stream_count, ret;
nut->avf = s; nut->avf = s;
/* main header */ /* main header */
pos = 0; pos = 0;
ret = 0;
do { do {
if (ret == AVERROR(ENOMEM))
return ret;
pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1; pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1;
if (pos < 0 + 1) { if (pos < 0 + 1) {
av_log(s, AV_LOG_ERROR, "No main startcode found.\n"); av_log(s, AV_LOG_ERROR, "No main startcode found.\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
} while (decode_main_header(nut) < 0); } while ((ret = decode_main_header(nut)) < 0);
/* stream headers */ /* stream headers */
pos = 0; pos = 0;