aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-02-04 15:58:11 +0100
committerAnton Khirnov <anton@khirnov.net>2014-02-10 15:08:06 +0100
commit394fb56c29eee7f4f8f0334d8b5d30d3c54ac703 (patch)
tree957284729dec1fabad8c571f9de4b786fc2f6737 /libavformat/mux.c
parent682b2a809b446c4ca45f88a84c1d92ccfcbcfbd1 (diff)
downloadffmpeg-394fb56c29eee7f4f8f0334d8b5d30d3c54ac703.tar.gz
lavf: always unref the packet passed to av_interleaved_write_frame() on error
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index c16d1c83a5..59f9c42cf1 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -619,22 +619,26 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
ret = check_packet(s, pkt);
if (ret < 0)
- return ret;
+ goto fail;
if (pkt) {
AVStream *st = s->streams[pkt->stream_index];
//FIXME/XXX/HACK drop zero sized packets
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->size == 0)
- return 0;
+ if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->size == 0) {
+ ret = 0;
+ goto fail;
+ }
av_dlog(s, "av_interleaved_write_frame size:%d dts:%" PRId64 " pts:%" PRId64 "\n",
pkt->size, pkt->dts, pkt->pts);
if ((ret = compute_pkt_fields2(s, st, pkt)) < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
- return ret;
+ goto fail;
- if (pkt->dts == AV_NOPTS_VALUE && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
- return AVERROR(EINVAL);
+ if (pkt->dts == AV_NOPTS_VALUE && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
+ ret = AVERROR(EINVAL);
+ goto fail;
+ }
} else {
av_dlog(s, "av_interleaved_write_frame FLUSH\n");
flush = 1;
@@ -643,6 +647,11 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
for (;; ) {
AVPacket opkt;
int ret = interleave_packet(s, &opkt, pkt, flush);
+ if (pkt) {
+ memset(pkt, 0, sizeof(*pkt));
+ av_init_packet(pkt);
+ pkt = NULL;
+ }
if (ret <= 0) //FIXME cleanup needed for ret<0 ?
return ret;
@@ -651,11 +660,13 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
s->streams[opkt.stream_index]->nb_frames++;
av_free_packet(&opkt);
- pkt = NULL;
if (ret < 0)
return ret;
}
+fail:
+ av_packet_unref(pkt);
+ return ret;
}
int av_write_trailer(AVFormatContext *s)