Commit 1ca87d60 authored by Martin Storsjö's avatar Martin Storsjö

applehttpproto: Use the close function if the open function fails

This should clean up leaked memory.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent abe20c59
...@@ -174,6 +174,17 @@ fail: ...@@ -174,6 +174,17 @@ fail:
return ret; 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) static int applehttp_open(URLContext *h, const char *uri, int flags)
{ {
AppleHTTPContext *s; AppleHTTPContext *s;
...@@ -229,7 +240,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags) ...@@ -229,7 +240,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
return 0; return 0;
fail: fail:
av_free(s); applehttp_close(h);
return ret; return ret;
} }
...@@ -287,17 +298,6 @@ retry: ...@@ -287,17 +298,6 @@ retry:
goto start; 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 = { URLProtocol ff_applehttp_protocol = {
.name = "applehttp", .name = "applehttp",
.url_open = applehttp_open, .url_open = applehttp_open,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment