diff --git a/stl/src/tzdb.cpp b/stl/src/tzdb.cpp index 720064fefc..511951451b 100644 --- a/stl/src/tzdb.cpp +++ b/stl/src/tzdb.cpp @@ -567,7 +567,31 @@ void __stdcall __std_tzdb_delete_current_zone(__std_tzdb_current_zone_info* cons _Info->_Abbrev = _Allocate_wide_to_narrow(_Abbrev.get(), _Abbrev_len, _Info->_Err); if (_Info->_Abbrev == nullptr) { - return _Propagate_error(_Info); + const auto _Abs_offset = _Info->_Offset < 0 ? -_Info->_Offset : _Info->_Offset; + const auto _Offset_in_minutes = _Abs_offset / (60 * 1000); + const auto _Hours = _Offset_in_minutes / 60; + const auto _Mins = _Offset_in_minutes % 60; + + _STD unique_ptr _Fallback_abbrev{new (_STD nothrow) char[_Mins == 0 ? 4 : 6]}; + + if (_Fallback_abbrev == nullptr) { + return nullptr; + } + + _Fallback_abbrev[0] = _Info->_Offset < 0 ? '-' : '+'; + _Fallback_abbrev[1] = static_cast('0' + _Hours / 10); + _Fallback_abbrev[2] = static_cast('0' + _Hours % 10); + + if (_Mins == 0) { + _Fallback_abbrev[3] = '\0'; + } else { + _Fallback_abbrev[3] = static_cast('0' + _Mins / 10); + _Fallback_abbrev[4] = static_cast('0' + _Mins % 10); + _Fallback_abbrev[5] = '\0'; + } + + _Info->_Err = __std_tzdb_error::_Success; + _Info->_Abbrev = _Fallback_abbrev.release(); } return _Info.release();