From 1f5aebead0de51e2c2442107a51e3b215deb5cc8 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Wed, 22 Sep 2021 19:32:00 +0200 Subject: [PATCH] Fixed: Check that getenv("LANG") is not NULL in UTF-8 check --- src/btop.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/btop.cpp b/src/btop.cpp index b968993..50502b5 100644 --- a/src/btop.cpp +++ b/src/btop.cpp @@ -719,9 +719,9 @@ int main(int argc, char **argv) { //? Try to find and set a UTF-8 locale if (bool found = false; not str_to_upper(s_replace((string)std::setlocale(LC_ALL, NULL), "-", "")).ends_with("UTF8")) { - if (const string lang = (string)getenv("LANG"); str_to_upper(s_replace(lang, "-", "")).ends_with("UTF8")) { + if (getenv("LANG") != NULL and str_to_upper(s_replace((string)getenv("LANG"), "-", "")).ends_with("UTF8")) { found = true; - std::setlocale(LC_ALL, lang.c_str()); + std::setlocale(LC_ALL, getenv("LANG")); } else { setenv("LANG", "", 1);