mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-28 06:56:01 -05:00
[spotify_webapi] Fix memory leaks
This commit is contained in:
parent
583a968775
commit
825236c8bb
@ -136,7 +136,7 @@ jparse_str_from_array(json_object *array, int index, const char *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
http_client_ctx_free(struct http_client_ctx *ctx)
|
free_http_client_ctx(struct http_client_ctx *ctx)
|
||||||
{
|
{
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return;
|
return;
|
||||||
@ -240,13 +240,19 @@ tokens_get(struct keyval *kv, const char **err)
|
|||||||
goto out_free_input_body;
|
goto out_free_input_body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(spotify_access_token);
|
||||||
|
spotify_access_token = NULL;
|
||||||
|
|
||||||
tmp = jparse_str_from_obj(haystack, "access_token");
|
tmp = jparse_str_from_obj(haystack, "access_token");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
spotify_access_token = strdup(tmp);
|
spotify_access_token = strdup(tmp);
|
||||||
|
|
||||||
tmp = jparse_str_from_obj(haystack, "refresh_token");
|
tmp = jparse_str_from_obj(haystack, "refresh_token");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
spotify_refresh_token = strdup(tmp);
|
{
|
||||||
|
free(spotify_refresh_token);
|
||||||
|
spotify_refresh_token = strdup(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
expires_in = jparse_int_from_obj(haystack, "expires_in");
|
expires_in = jparse_int_from_obj(haystack, "expires_in");
|
||||||
if (expires_in == 0)
|
if (expires_in == 0)
|
||||||
@ -408,7 +414,7 @@ request_uri(struct spotify_request *request, const char *uri)
|
|||||||
void
|
void
|
||||||
spotifywebapi_request_end(struct spotify_request *request)
|
spotifywebapi_request_end(struct spotify_request *request)
|
||||||
{
|
{
|
||||||
http_client_ctx_free(request->ctx);
|
free_http_client_ctx(request->ctx);
|
||||||
jparse_free(request->haystack);
|
jparse_free(request->haystack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +422,6 @@ int
|
|||||||
spotifywebapi_request_next(struct spotify_request *request, const char *uri)
|
spotifywebapi_request_next(struct spotify_request *request, const char *uri)
|
||||||
{
|
{
|
||||||
char *next_uri;
|
char *next_uri;
|
||||||
const char *tmp;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (request->ctx && !request->next_uri)
|
if (request->ctx && !request->next_uri)
|
||||||
@ -444,9 +449,7 @@ spotifywebapi_request_next(struct spotify_request *request, const char *uri)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
request->total = jparse_int_from_obj(request->haystack, "total");
|
request->total = jparse_int_from_obj(request->haystack, "total");
|
||||||
tmp = jparse_str_from_obj(request->haystack, "next");
|
request->next_uri = jparse_str_from_obj(request->haystack, "next");
|
||||||
if (tmp)
|
|
||||||
request->next_uri = strdup(tmp);
|
|
||||||
|
|
||||||
if (jparse_array_from_obj(request->haystack, "items", &request->items) < 0)
|
if (jparse_array_from_obj(request->haystack, "items", &request->items) < 0)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,7 @@ struct spotify_request
|
|||||||
json_object *items;
|
json_object *items;
|
||||||
int count;
|
int count;
|
||||||
int total;
|
int total;
|
||||||
char *next_uri;
|
const char *next_uri;
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user