Commit 7a1b6c9025 for ffmpeg
commit 7a1b6c9025084b893cbf325327879ec8c3158e3b
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Sat Nov 28 22:44:45 2026 +0100
avformat/whip: fix leak of the RTP buffer when avformat_write_header() fails
avio_context_free() does not free the buffer passed to
avio_alloc_context().
Found while fixing the double free of the same buffer
diff --git a/libavformat/whip.c b/libavformat/whip.c
index 114e098985..900ee0164b 100644
--- a/libavformat/whip.c
+++ b/libavformat/whip.c
@@ -693,8 +693,10 @@ static int create_rtp_muxer(AVFormatContext *s)
RTC_ELAPSED(rtc->dtls_time, rtc->srtp_time));
end:
- if (rtp_ctx)
+ if (rtp_ctx && rtp_ctx->pb) {
+ av_freep(&rtp_ctx->pb->buffer);
avio_context_free(&rtp_ctx->pb);
+ }
avformat_free_context(rtp_ctx);
av_dict_free(&opts);
return ret;