From 7bb5c80d04be5e5297fb6259e487fe0105e85935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Fri, 16 Dec 2022 08:38:37 +0100 Subject: [PATCH] main: Graceful fallback if user has configured an invalid locale --- main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index c882c825..4af200fd 100644 --- a/main.c +++ b/main.c @@ -433,8 +433,13 @@ main(int argc, char *const *argv) const char *locale = setlocale(LC_CTYPE, ""); if (locale == NULL) { - LOG_ERR("setlocale() failed"); - return ret; + /* + * If the user has configured an invalid locale, or a name of a locale + * that does not exist on this system, then the above call may return + * NULL. We should just continue with the fallback method below. + */ + LOG_WARN("setlocale() failed"); + locale = "C"; } LOG_INFO("locale: %s", locale);