[2/7] crypto: Don't manually free memory allocated via AVOptions

Message ID 1320794165-24248-2-git-send-email-martin@martin.st
State Committed
Commit eaa8c1f9fe254ea0e370e57fec1f5439a50894e8
Headers show

Commit Message

Martin Storsjö Nov. 8, 2011, 11:16 p.m.
---
 libavformat/crypto.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

Comments

Anton Khirnov Nov. 10, 2011, 8:38 a.m. | #1
On Wed,  9 Nov 2011 01:16:00 +0200, Martin Storsjö <martin@martin.st> wrote:
> ---
>  libavformat/crypto.c |    7 +------
>  1 files changed, 1 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/crypto.c b/libavformat/crypto.c
> index b9d3e03..2f0e2bd 100644
> --- a/libavformat/crypto.c
> +++ b/libavformat/crypto.c
> @@ -61,7 +61,7 @@ static const AVClass crypto_class = {
>  static int crypto_open(URLContext *h, const char *uri, int flags)
>  {
>      const char *nested_url;
> -    int ret;
> +    int ret = 0;
>      CryptoContext *c = h->priv_data;
>  
>      if (!av_strstart(uri, "crypto+", &nested_url) &&
> @@ -95,10 +95,7 @@ static int crypto_open(URLContext *h, const char *uri, int flags)
>  
>      h->is_streamed = 1;
>  
> -    return 0;
>  err:
> -    av_freep(&c->key);
> -    av_freep(&c->iv);
>      return ret;
>  }
>  
> @@ -157,8 +154,6 @@ static int crypto_close(URLContext *h)
>      if (c->hd)
>          ffurl_close(c->hd);
>      av_freep(&c->aes);
> -    av_freep(&c->key);
> -    av_freep(&c->iv);
>      return 0;
>  }
>  

Ok.

Patch

diff --git a/libavformat/crypto.c b/libavformat/crypto.c
index b9d3e03..2f0e2bd 100644
--- a/libavformat/crypto.c
+++ b/libavformat/crypto.c
@@ -61,7 +61,7 @@  static const AVClass crypto_class = {
 static int crypto_open(URLContext *h, const char *uri, int flags)
 {
     const char *nested_url;
-    int ret;
+    int ret = 0;
     CryptoContext *c = h->priv_data;
 
     if (!av_strstart(uri, "crypto+", &nested_url) &&
@@ -95,10 +95,7 @@  static int crypto_open(URLContext *h, const char *uri, int flags)
 
     h->is_streamed = 1;
 
-    return 0;
 err:
-    av_freep(&c->key);
-    av_freep(&c->iv);
     return ret;
 }
 
@@ -157,8 +154,6 @@  static int crypto_close(URLContext *h)
     if (c->hd)
         ffurl_close(c->hd);
     av_freep(&c->aes);
-    av_freep(&c->key);
-    av_freep(&c->iv);
     return 0;
 }