mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-28 16:15:57 -05:00
Fix memleak in artwork.c
This commit is contained in:
parent
56ece92209
commit
50ef710549
@ -707,41 +707,44 @@ artwork_get_player_image(char *path, int max_w, int max_h, struct evbuffer *evbu
|
|||||||
|
|
||||||
DPRINTF(E_DBG, L_ART, "Trying internet stream artwork in %s\n", path);
|
DPRINTF(E_DBG, L_ART, "Trying internet stream artwork in %s\n", path);
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
player_icy_artwork_url(&url, path);
|
player_icy_artwork_url(&url, path);
|
||||||
if (!url)
|
if (!url)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
len = strlen(url);
|
len = strlen(url);
|
||||||
if ((len < 14) || (len > PATH_MAX)) // Can't be shorter than http://a/1.jpg
|
if ((len < 14) || (len > PATH_MAX)) // Can't be shorter than http://a/1.jpg
|
||||||
return 0;
|
goto out_url;
|
||||||
|
|
||||||
kv = keyval_alloc();
|
kv = keyval_alloc();
|
||||||
if (!kv)
|
if (!kv)
|
||||||
return 0;
|
goto out_url;
|
||||||
|
|
||||||
memset(&ctx, 0, sizeof(ctx));
|
memset(&ctx, 0, sizeof(ctx));
|
||||||
ctx.url = url;
|
ctx.url = url;
|
||||||
ctx.headers = kv;
|
ctx.headers = kv;
|
||||||
ctx.body = evbuf;
|
ctx.body = evbuf;
|
||||||
|
|
||||||
ret = http_client_request(&ctx);
|
if (http_client_request(&ctx) < 0)
|
||||||
if (ret < 0)
|
goto out_kv;
|
||||||
return 0;
|
|
||||||
|
|
||||||
content_type = keyval_get(kv, "Content-Type");
|
content_type = keyval_get(kv, "Content-Type");
|
||||||
if (strcmp(content_type, "image/jpeg") == 0)
|
if (content_type && (strcmp(content_type, "image/jpeg") == 0))
|
||||||
ret = ART_FMT_JPEG;
|
ret = ART_FMT_JPEG;
|
||||||
else if (strcmp(content_type, "image/png") == 0)
|
else if (content_type && (strcmp(content_type, "image/png") == 0))
|
||||||
ret = ART_FMT_PNG;
|
ret = ART_FMT_PNG;
|
||||||
else
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
DPRINTF(E_DBG, L_ART, "Found internet stream artwork in %s (%s)\n", url, content_type);
|
DPRINTF(E_DBG, L_ART, "Found internet stream artwork in %s (%s)\n", url, content_type);
|
||||||
|
|
||||||
|
out_kv:
|
||||||
keyval_clear(kv);
|
keyval_clear(kv);
|
||||||
free(kv);
|
free(kv);
|
||||||
|
|
||||||
|
out_url:
|
||||||
|
free(url);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user