diff --git a/stl/src/xdateord.cpp b/stl/src/xdateord.cpp index fbf8239fbc5..312d96d7155 100644 --- a/stl/src/xdateord.cpp +++ b/stl/src/xdateord.cpp @@ -10,8 +10,13 @@ _EXTERN_C_UNLESS_PURE _CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Getdateorder() noexcept { // return date order for current locale + const wchar_t* const locale_name = ___lc_locale_name_func()[LC_TIME]; + if (locale_name == nullptr) { // Indicates "C" locale; GetLocaleInfoEx would see this as LOCALE_NAME_USER_DEFAULT + return std::time_base::mdy; + } + wchar_t buf[2] = {0}; - GetLocaleInfoEx(___lc_locale_name_func()[LC_TIME], LOCALE_ILDATE, buf, static_cast(std::size(buf))); + GetLocaleInfoEx(locale_name, LOCALE_ILDATE, buf, static_cast(std::size(buf))); switch (buf[0]) { case L'0':