[FFmpeg-devel] Memory leak in rtmp_open()

Andrey Myznikov andrey.myznikov at gmail.com
Mon Jan 13 13:13:48 CET 2014


Hello all,
     attached is little path to libavformat/librtmp.c fixes potential 
memory and socket loss in rtmp_open().
The reason is that RTMP_ConnectStream() does not call to RTMP_Close() on 
error.
Observed actually with trial version of Adobe Flash Media Server 
limiting number of simultaneous connections.

Regards!
  Andrey Myznikov
----------------------

 From 124e1d08264d0a396a668a249c71a0b7c89c5dcf Mon Sep 17 00:00:00 2001
From: Andrey Myznikov <andrey.myznikov at gmail.com>
Date: Mon, 13 Jan 2014 13:40:55 +0200
Subject: [PATCH] rtmp_open(): Fix memory leak if RTMP_ConnectStream() fails

---
  libavformat/librtmp.c |    9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index 5b4c39d..474cd55 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -124,11 +124,18 @@ static int rtmp_open(URLContext *s, const char 
*uri, int flags)
      if (flags & AVIO_FLAG_WRITE)
          RTMP_EnableWrite(r);

-    if (!RTMP_Connect(r, NULL) || !RTMP_ConnectStream(r, 0)) {
+    if (!RTMP_Connect(r, NULL) ) {
          rc = AVERROR_UNKNOWN;
          goto fail;
      }

+    if ( !RTMP_ConnectStream(r, 0) ) {
+        RTMP_Close(r);
+        rc = AVERROR_UNKNOWN;
+        goto fail;
+    }
+
+
      s->is_streamed = 1;
      rc = 0;
  fail:
-- 
1.7.10.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-rtmp_open-Fix-memory-leak-if-RTMP_ConnectStream-fail.patch
Type: text/x-patch
Size: 972 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140113/851e3ad4/attachment.bin>


More information about the ffmpeg-devel mailing list