From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg_mux: avoid leaking pkt on errors
Date: Wed, 10 Aug 2022 18:25:38 +0200
Message-ID: <20220810162545.21382-2-anton@khirnov.net> (raw)
In-Reply-To: <20220810162545.21382-1-anton@khirnov.net>
---
fftools/ffmpeg_mux.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 08a76f0066..b424ef0021 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -97,8 +97,10 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
fs = filesize(s->pb);
atomic_store(&of->mux->last_filesize, fs);
- if (fs >= of->mux->limit_filesize)
- return AVERROR_EOF;
+ if (fs >= of->mux->limit_filesize) {
+ ret = AVERROR_EOF;
+ goto fail;
+ }
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) ||
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
@@ -138,8 +140,11 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
av_log(s, loglevel, "Non-monotonous DTS in output stream "
"%d:%d; previous: %"PRId64", current: %"PRId64"; ",
ost->file_index, ost->st->index, ms->last_mux_dts, pkt->dts);
- if (exit_on_error)
- return AVERROR(EINVAL);
+ if (exit_on_error) {
+ ret = AVERROR(EINVAL);
+ goto fail;
+ }
+
av_log(s, loglevel, "changing to %"PRId64". This may result "
"in incorrect timestamps in the output file.\n",
max);
@@ -170,10 +175,13 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
ret = av_interleaved_write_frame(s, pkt);
if (ret < 0) {
print_error("av_interleaved_write_frame()", ret);
- return ret;
+ goto fail;
}
return 0;
+fail:
+ av_packet_unref(pkt);
+ return ret;
}
static int sync_queue_process(OutputFile *of, OutputStream *ost, AVPacket *pkt)
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-08-10 16:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-10 16:25 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: mark all encode sync queues as done before flushing encoders Anton Khirnov
2022-08-10 16:25 ` Anton Khirnov [this message]
2022-08-10 16:25 ` [FFmpeg-devel] [PATCH 3/9] fftools/ffmpeg: move stream-dependent starttime correction to transcode_init() Anton Khirnov
2022-08-10 22:33 ` Michael Niedermayer
2022-08-11 7:45 ` [FFmpeg-devel] [PATCH] " Anton Khirnov
2022-08-12 15:43 ` Michael Niedermayer
2022-08-10 16:25 ` [FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg: pre-compute the streamcopy start pts before transcoding starts Anton Khirnov
2022-08-10 16:25 ` [FFmpeg-devel] [PATCH 5/9] fftools/ffmpeg: move timestamp discontinuity correction out of process_input() Anton Khirnov
2022-08-10 16:25 ` [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: move inter-stream ts discontinuity handling to ts_discontinuity_process() Anton Khirnov
2022-08-10 16:25 ` [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg: simplify conditions in ts_discontinuity_process Anton Khirnov
2022-08-10 16:25 ` [FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg: use a separate variable for discontinuity offset Anton Khirnov
2022-08-10 16:25 ` [FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: move packet timestamp processing to demuxer thread Anton Khirnov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220810162545.21382-2-anton@khirnov.net \
--to=anton@khirnov.net \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git