summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2011-12-01 11:07:35 +0200
committerMartin Storsjö <martin@martin.st>2011-12-01 13:47:23 +0200
commit1ca87d600bc069fe4cf497c410b4f794e88a122d (patch)
tree590ec66f253bd40a210930b21f1c34fcc8e88db4
parentabe20c59b93426958624e16e89b24e0c0b43f370 (diff)
applehttpproto: Use the close function if the open function fails
This should clean up leaked memory. Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r--libavformat/applehttpproto.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index 0e64dadb39..8dbcf2d394 100644
--- a/libavformat/applehttpproto.c
+++ b/libavformat/applehttpproto.c
@@ -174,6 +174,17 @@ fail:
return ret;
}
+static int applehttp_close(URLContext *h)
+{
+ AppleHTTPContext *s = h->priv_data;
+
+ free_segment_list(s);
+ free_variant_list(s);
+ ffurl_close(s->seg_hd);
+ av_free(s);
+ return 0;
+}
+
static int applehttp_open(URLContext *h, const char *uri, int flags)
{
AppleHTTPContext *s;
@@ -229,7 +240,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
return 0;
fail:
- av_free(s);
+ applehttp_close(h);
return ret;
}
@@ -287,17 +298,6 @@ retry:
goto start;
}
-static int applehttp_close(URLContext *h)
-{
- AppleHTTPContext *s = h->priv_data;
-
- free_segment_list(s);
- free_variant_list(s);
- ffurl_close(s->seg_hd);
- av_free(s);
- return 0;
-}
-
URLProtocol ff_applehttp_protocol = {
.name = "applehttp",
.url_open = applehttp_open,