From 5b2e98125331fc286d8923fa14335383f2c82a05 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Wed, 5 Nov 2008 21:40:08 +0100
Subject: log: check if log_charset is set

When logging to a file, log_charset would be NULL and g_convert()
would abort.
---
 src/log.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

(limited to 'src/log.c')

diff --git a/src/log.c b/src/log.c
index f0c8a9cad..db6cb7e3f 100644
--- a/src/log.c
+++ b/src/log.c
@@ -75,11 +75,14 @@ mpd_log_func(G_GNUC_UNUSED const gchar *log_domain,
 		? stderr : stdout;
 	char *converted;
 
-	converted = g_convert_with_fallback(message, -1,
-					    log_charset, "utf-8",
-					    NULL, NULL, NULL, NULL);
-	if (converted != NULL)
-		message = converted;
+	if (log_charset != NULL) {
+		converted = g_convert_with_fallback(message, -1,
+						    log_charset, "utf-8",
+						    NULL, NULL, NULL, NULL);
+		if (converted != NULL)
+			message = converted;
+	} else
+		converted = NULL;
 
 	fprintf(file, "%s%s",
 		stdout_mode ? "" : log_date(),
-- 
cgit v1.2.3