Docs clearly states that av_write_trailer should only be called if
avformat_write_header was successful, therefore we have to deinit if we return
failure.
Signed-off-by: Marton Balint <cus@passwd.hu>
if (ret >= 0 && s->pb && s->pb->error < 0)
ret = s->pb->error;
if (ret < 0)
- return ret;
+ goto fail;
if (s->flush_packets && s->pb && s->pb->error >= 0 && s->flags & AVFMT_FLAG_FLUSH_PACKETS)
avio_flush(s->pb);
s->internal->header_written = 1;
}
if ((ret = init_pts(s)) < 0)
- return ret;
+ goto fail;
if (s->avoid_negative_ts < 0) {
av_assert2(s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO);
}
return 0;
+
+fail:
+ if (s->oformat->deinit)
+ s->oformat->deinit(s);
+ return ret;
}
#define AV_PKT_FLAG_UNCODED_FRAME 0x2000