From: toots via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: toots <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] Handle errors in ogg reinit, make sure we free private data before new (PR #20877)
Date: Sun, 09 Nov 2025 18:51:45 -0000
Message-ID: <176271430621.25.6666731293288448218@2cb04c0e5124> (raw)
PR #20877 opened by toots
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20877
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20877.patch
>From 389a1df1e310c7a76f857137d321d455271d5719 Mon Sep 17 00:00:00 2001
From: Romain Beauxis <romain.beauxis@gmail.com>
Date: Sun, 9 Nov 2025 12:49:32 -0600
Subject: [PATCH] Handle errors in ogg reinit, make sure we free private data
before new init.
---
libavformat/oggenc.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 5cd94b49bc..080af2295f 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -649,16 +649,27 @@ static int ogg_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
side_metadata = av_packet_get_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, &size);
if (side_metadata && oggstream->packet_written) {
- ogg_write_trailer(s);
+ ret = ogg_write_trailer(s);
+ if (ret < 0)
+ return ret;
+
ogg_deinit(s);
+ av_freep(&st->priv_data);
av_dict_free(&st->metadata);
ret = av_packet_unpack_dictionary(side_metadata, size, &st->metadata);
if (ret < 0)
return ret;
- ogg_init(s);
- ogg_write_header(s);
+ ret = ogg_init(s);
+ if (ret < 0)
+ return ret;
+
+ oggstream = st->priv_data;
+
+ ret = ogg_write_header(s);
+ if (ret < 0)
+ return ret;
}
oggstream->packet_written = 1;
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-11-09 18:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=176271430621.25.6666731293288448218@2cb04c0e5124 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@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