Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] fftools/ffmpeg: fix memleak when sdp create failed (PR #20969)
@ 2025-11-19 11:56 Jack Lau via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Jack Lau via ffmpeg-devel @ 2025-11-19 11:56 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jack Lau

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-11-19 11:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-19 11:56 [FFmpeg-devel] [PATCH] fftools/ffmpeg: fix memleak when sdp create failed (PR #20969) Jack Lau via ffmpeg-devel

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