mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-04 02:16:01 -05:00
Don't cast to char with malloc and some error handling
This commit is contained in:
parent
b3ea04a047
commit
b5247aab1d
7
src/db.c
7
src/db.c
@ -1275,7 +1275,12 @@ db_build_query_browse(struct query_params *qp, char *field, char *sort_field, ch
|
||||
else
|
||||
{
|
||||
size = strlen("ORDER BY f.") + strlen(field) + 1;
|
||||
sort = (char *)malloc(size);
|
||||
sort = malloc(size);
|
||||
if (!sort)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Out of memory for sort string\n");
|
||||
return -1;
|
||||
}
|
||||
snprintf(sort, size, "ORDER BY f.%s", field);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user