From f1a2b8d33b6cc1cbe8b70011fc4c5fac81bdc0a6 Mon Sep 17 00:00:00 2001 From: Hugues Morisset Date: Fri, 23 Sep 2022 23:16:03 +0200 Subject: [PATCH] Return "" locale when parameter is null --- libc/str/langinfo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libc/str/langinfo.c b/libc/str/langinfo.c index 41aad1030..a42c201e4 100644 --- a/libc/str/langinfo.c +++ b/libc/str/langinfo.c @@ -66,6 +66,9 @@ char *nl_langinfo_l(nl_item item, locale_t loc) int idx = item & 65535; const char *str; + if (!loc) + return ""; + if (item == CODESET) return loc->cat[LC_CTYPE] ? "UTF-8" : "ASCII"; /* _NL_LOCALE_NAME extension */