mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-02 17:36:00 -05:00
Minor adjustment so Valgrind is happy with string handling in user_agent_filter
This commit is contained in:
parent
a3f0145561
commit
7e2f47f9ca
@ -489,6 +489,9 @@ user_agent_filter(const char *user_agent, struct query_params *qp)
|
|||||||
if (!user_agent)
|
if (!user_agent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Valgrind doesn't like strlen(filter) below, so instead we allocate 128 bytes
|
||||||
|
// to hold the string and the leading " AND ". Remember to adjust the 128 if
|
||||||
|
// you define strings here that will be too large for the buffer.
|
||||||
if (strcasestr(user_agent, "itunes"))
|
if (strcasestr(user_agent, "itunes"))
|
||||||
filter = strdup("(f.data_kind = 0)"); // Only real files
|
filter = strdup("(f.data_kind = 0)"); // Only real files
|
||||||
else if (strcasestr(user_agent, "daap"))
|
else if (strcasestr(user_agent, "daap"))
|
||||||
@ -502,9 +505,9 @@ user_agent_filter(const char *user_agent, struct query_params *qp)
|
|||||||
|
|
||||||
if (qp->filter)
|
if (qp->filter)
|
||||||
{
|
{
|
||||||
len = strlen(qp->filter) + strlen(" AND ") + strlen(filter);
|
len = strlen(qp->filter) + 128;
|
||||||
buffer = (char *)malloc(len + 1);
|
buffer = (char *)malloc(len);
|
||||||
snprintf(buffer, len + 1, "%s AND %s", qp->filter, filter);
|
snprintf(buffer, len, "%s AND %s", qp->filter, filter);
|
||||||
free(qp->filter);
|
free(qp->filter);
|
||||||
qp->filter = strdup(buffer);
|
qp->filter = strdup(buffer);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user