Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Marvin Scholz via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Marvin Scholz <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] avformat: fix leaks in rtsp_read_command_reply and seq logging (PR #21805)
Date: Thu, 19 Feb 2026 19:35:08 -0000
Message-ID: <177152970849.25.17553805234310938153@29965ddac10e> (raw)

PR #21805 opened by Marvin Scholz (ePirat)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21805
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21805.patch


>From ee555af62a05ad8121d87bceba755f3c1ec6469d Mon Sep 17 00:00:00 2001
From: Marvin Scholz <epirat07@gmail.com>
Date: Thu, 19 Feb 2026 20:27:41 +0100
Subject: [PATCH 1/2] avformat: rtspdec: fix leaks in rtsp_read_command_reply

Reorder to avoid allocation if there is nothing to read and also solve
a memory leak in that case.

Also make sure to free the RTSPMessageHeader, which is not passed
to the caller.
---
 libavformat/rtspdec.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index 1fd50bf9be..c92df06b46 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -674,17 +674,21 @@ static int rtsp_read_command_reply(AVFormatContext *s, enum AVFormatCommandID id
     if (!data_out)
         return AVERROR(EINVAL);
 
-    AVRTSPResponse *res = av_malloc(sizeof(*res));
-    if (!res)
-        return AVERROR(ENOMEM);
-
+    unsigned char *body;
     RTSPMessageHeader *reply;
-    int ret = ff_rtsp_read_reply_async_stored(s, &reply, &res->body);
+    int ret = ff_rtsp_read_reply_async_stored(s, &reply, &body);
     if (ret < 0)
         return ret;
 
+    AVRTSPResponse *res = av_malloc(sizeof(*res));
+    if (!res) {
+        av_free(body);
+        return AVERROR(ENOMEM);
+    }
+
     res->status_code = reply->status_code;
     res->body_len = reply->content_length;
+    res->body = body;
 
     res->reason = av_strdup(reply->reason);
     if (!res->reason) {
@@ -694,6 +698,7 @@ static int rtsp_read_command_reply(AVFormatContext *s, enum AVFormatCommandID id
         return AVERROR(ENOMEM);
     }
 
+    av_free(reply);
     *data_out = res;
     return 0;
 }
-- 
2.52.0


>From 80ac2fca2beb31d5e3cbc025d2a2474e2f66cbd3 Mon Sep 17 00:00:00 2001
From: Marvin Scholz <epirat07@gmail.com>
Date: Thu, 19 Feb 2026 20:28:19 +0100
Subject: [PATCH 2/2] avformat: rtsp: fix logging of reply sequence number

---
 libavformat/rtsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 1362cb683b..822780087d 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1415,7 +1415,7 @@ int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
             memcpy(rt->stored_msg.header, &header, sizeof(header));
         } else {
             av_log(s, AV_LOG_WARNING, "Unexpected reply with seq %d, expected %d\n",
-                rt->stored_msg.header->seq, rt->stored_msg.expected_seq);
+                header.seq, rt->stored_msg.expected_seq);
             av_freep(&rt->stored_msg.body);
         }
 
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2026-02-19 19:35 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=177152970849.25.17553805234310938153@29965ddac10e \
    --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