Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Jack Lau via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Jack Lau <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg: fix memleak when sdp create failed (PR #20969)
Date: Wed, 19 Nov 2025 11:56:18 -0000
Message-ID: <176355337901.59.14729924145596149116@2cb04c0e5124> (raw)

PR #20969 opened by Jack Lau (JackLau)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20969
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20969.patch

Fix #20712

When print_sdp() fails during rtp streaming, sch_start()
returns error code without calling wirte_trailer, causing
a memory leak.

Since mux->init() (rtp_write_header) already run before
print_sdp(), so we should wirte_trailer() before exit program.

The av_write_trailer() only runs when mux->header_written is
ture so this change won't break other case.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>


>From 063e729243a76e71cb7ee9f13d1d723ea1f135cf Mon Sep 17 00:00:00 2001
From: Jack Lau <jacklau1222gm@gmail.com>
Date: Wed, 19 Nov 2025 19:35:37 +0800
Subject: [PATCH] fftools/ffmpeg: fix memleak when sdp create failed

Fix #20712

When print_sdp() fails during rtp streaming, sch_start()
returns error code without calling wirte_trailer, causing
a memory leak.

Since mux->init() (rtp_write_header) already run before
print_sdp(), so we should wirte_trailer() before exit program.

The av_write_trailer() only runs when mux->header_written is
ture so this change won't break other case.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
---
 fftools/ffmpeg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 444d027c15..12707782f6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -891,7 +891,7 @@ static int transcode(Scheduler *sch)
 
     ret = sch_start(sch);
     if (ret < 0)
-        return ret;
+        goto end;
 
     if (stdin_interaction) {
         av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
@@ -915,7 +915,7 @@ static int transcode(Scheduler *sch)
     }
 
     ret = sch_stop(sch, &transcode_ts);
-
+end:
     /* write the trailer if needed */
     for (int i = 0; i < nb_output_files; i++) {
         int err = of_write_trailer(output_files[i]);
-- 
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-19 11:56 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=176355337901.59.14729924145596149116@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