[4/7] rtmp: Clean up properly if the handshake failed

Message ID 1322734056-84812-4-git-send-email-martin@martin.st
State Committed
Commit 02490bf3587d86a730e0de12572026504e2cb942
Headers show

Commit Message

Martin Storsjö Dec. 1, 2011, 10:07 a.m.
This prevents memory leaks if this function returns an error.
---
 libavformat/rtmpproto.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Kostya Shishkov Dec. 1, 2011, 10:09 a.m. | #1
On Thu, Dec 01, 2011 at 12:07:33PM +0200, Martin Storsjö wrote:
> This prevents memory leaks if this function returns an error.
> ---
>  libavformat/rtmpproto.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
> index 37c3d95..979c5b6 100644
> --- a/libavformat/rtmpproto.c
> +++ b/libavformat/rtmpproto.c
> @@ -826,7 +826,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
>  
>      rt->state = STATE_START;
>      if (rtmp_handshake(s, rt))
> -        return -1;
> +        goto fail;
>  
>      rt->chunk_size = 128;
>      rt->state = STATE_HANDSHAKED;
> -- 

looks OK

Patch

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 37c3d95..979c5b6 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -826,7 +826,7 @@  static int rtmp_open(URLContext *s, const char *uri, int flags)
 
     rt->state = STATE_START;
     if (rtmp_handshake(s, rt))
-        return -1;
+        goto fail;
 
     rt->chunk_size = 128;
     rt->state = STATE_HANDSHAKED;