[Ion] Prevent crash if locale is null (#365)

* fix a compilation issue

* revert file

---------

Co-authored-by: Leviathan3DPrinting <leviathan3dprinting@gmail.com>
This commit is contained in:
Leviathan3DPrinting
2024-05-12 06:35:12 -05:00
committed by GitHub
parent 891693abe2
commit ac71576acc

View File

@@ -8,7 +8,7 @@ namespace Platform {
const char * languageCode() {
static char buffer[3] = {0};
char * locale = setlocale(LC_ALL, "");
if (locale[2] == '_') {
if (locale && locale[2] == '_') { // Check if locale is not null before accessing its elements
buffer[0] = locale[0];
buffer[1] = locale[1];
return buffer;