Merge remote-tracking branch 'cehoyos/master'

* cehoyos/master:
  lavf/mux: Always call write_trailer() from av_write_trailer() to avoid a leak.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-11-20 11:41:27 +01:00
commit 9266eb0c62
1 changed files with 8 additions and 4 deletions

View File

@ -926,7 +926,7 @@ int av_write_trailer(AVFormatContext *s)
for (;; ) { for (;; ) {
AVPacket pkt; AVPacket pkt;
ret = interleave_packet(s, &pkt, NULL, 1); ret = interleave_packet(s, &pkt, NULL, 1);
if (ret < 0) //FIXME cleanup needed for ret<0 ? if (ret < 0)
goto fail; goto fail;
if (!ret) if (!ret)
break; break;
@ -943,10 +943,14 @@ int av_write_trailer(AVFormatContext *s)
goto fail; goto fail;
} }
if (s->oformat->write_trailer)
ret = s->oformat->write_trailer(s);
fail: fail:
if (s->oformat->write_trailer)
if (ret >= 0) {
ret = s->oformat->write_trailer(s);
} else {
s->oformat->write_trailer(s);
}
if (s->pb) if (s->pb)
avio_flush(s->pb); avio_flush(s->pb);
if (ret == 0) if (ret == 0)