From b5247aab1d0cf2f0714c9c767f37e55eccbcb049 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Sun, 15 Dec 2013 22:15:45 +0100 Subject: [PATCH] Don't cast to char with malloc and some error handling --- src/db.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/db.c b/src/db.c index bdb44cdf..974c959d 100644 --- a/src/db.c +++ b/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); }