summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar Fouillet <fouillet.edgar@outlook.fr>2019-09-25 18:36:54 +0200
committerjaseg <githubaccount@jaseg.net>2019-11-10 16:36:39 +0100
commit6e1caef075b973999cda4cac5b3fb40b6a4b5408 (patch)
treefc2a9f750e17f7f77e8bbd9ce42c7d71d8ce9388
parent35dca3d0a381496d7195cd78f5b24aa7b62f2154 (diff)
downloadlolcat-6e1caef075b973999cda4cac5b3fb40b6a4b5408.tar.gz
lolcat-6e1caef075b973999cda4cac5b3fb40b6a4b5408.tar.bz2
lolcat-6e1caef075b973999cda4cac5b3fb40b6a4b5408.zip
lolcat: Fix segfault on launch when LANG is undefined
Closes #27
-rw-r--r--lolcat.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lolcat.c b/lolcat.c
index a7fc7c3..5c62baf 100644
--- a/lolcat.c
+++ b/lolcat.c
@@ -138,7 +138,8 @@ int main(int argc, char** argv)
inputs_end = inputs + 1;
}
- if (force_locale && !strstr(getenv("LANG"), "UTF-8"))
+ char* env_lang = getenv("LANG");
+ if (force_locale && env_lang && !strstr(env_lang, "UTF-8"))
setlocale(LC_ALL, "C.UTF-8");
else
setlocale(LC_ALL, "");