avformat/nutenc: don't allocate a dynamic AVIOContext if no index is going to be written

Fixes ticket #8295

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1d479300cb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
James Almer 2019-10-18 20:53:10 -03:00 committed by Michael Niedermayer
parent c6fdee5274
commit 3a04214c60
1 changed files with 4 additions and 1 deletions

View File

@ -1171,8 +1171,11 @@ static int nut_write_trailer(AVFormatContext *s)
while (nut->header_count < 3)
write_headers(s, bc);
if (!nut->sp_count)
return 0;
ret = avio_open_dyn_buf(&dyn_bc);
if (ret >= 0 && nut->sp_count) {
if (ret >= 0) {
av_assert1(nut->write_index); // sp_count should be 0 if no index is going to be written
write_index(nut, dyn_bc);
put_packet(nut, bc, dyn_bc, 1, INDEX_STARTCODE);