This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new 5c6c12acb1 avformat/rtpenc: fix memleak when sdp create failed
5c6c12acb1 is described below

commit 5c6c12acb169c43fea8483e1e44ae492491d62bd
Author:     Jack Lau <[email protected]>
AuthorDate: Fri Nov 21 09:37:56 2025 +0800
Commit:     Marton Balint <[email protected]>
CommitDate: Tue Feb 3 23:31:17 2026 +0000

    avformat/rtpenc: 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.
    
    The avformat_free_context() will call the mux->deinit, so
    we should add a rtp_deinit() to free all internal allocations.
    
    Signed-off-by: Jack Lau <[email protected]>
---
 libavformat/rtpenc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 795229aca3..3602b081d5 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -679,11 +679,17 @@ static int rtp_write_trailer(AVFormatContext *s1)
      * be NULL here even if it was successfully allocated at the start. */
     if (s1->pb && (s->flags & FF_RTP_FLAG_SEND_BYE))
         rtcp_send_sr(s1, ff_ntp_time(), 1);
-    av_freep(&s->buf);
 
     return 0;
 }
 
+static void rtp_deinit(AVFormatContext *s1)
+{
+    RTPMuxContext *s = s1->priv_data;
+
+    av_freep(&s->buf);
+}
+
 const FFOutputFormat ff_rtp_muxer = {
     .p.name            = "rtp",
     .p.long_name       = NULL_IF_CONFIG_SMALL("RTP output"),
@@ -693,6 +699,7 @@ const FFOutputFormat ff_rtp_muxer = {
     .write_header      = rtp_write_header,
     .write_packet      = rtp_write_packet,
     .write_trailer     = rtp_write_trailer,
+    .deinit            = rtp_deinit,
     .p.priv_class      = &rtp_muxer_class,
     .p.flags           = AVFMT_NODIMENSIONS | AVFMT_TS_NONSTRICT,
 };

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to