Don't cast to char with malloc and some error handling

This commit is contained in:
ejurgensen 2013-12-15 22:15:45 +01:00
parent b3ea04a047
commit b5247aab1d

View File

@ -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);
}