diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 4b9fa6f8..504b3837 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1481,15 +1481,18 @@ bool Notepad_plus::fileSave(BufferID id) struct tm *today; today = localtime(<ime); - generic_strftime(tmpbuf, temBufLen, TEXT("%Y-%m-%d_%H%M%S"), today); + if (today) + { + generic_strftime(tmpbuf, temBufLen, TEXT("%Y-%m-%d_%H%M%S"), today); - fn_bak += name; - fn_bak += TEXT("."); - fn_bak += tmpbuf; - fn_bak += TEXT(".bak"); + fn_bak += name; + fn_bak += TEXT("."); + fn_bak += tmpbuf; + fn_bak += TEXT(".bak"); + } } - if (not ::CopyFile(fn, fn_bak.c_str(), FALSE)) + if (!::CopyFile(fn, fn_bak.c_str(), FALSE)) { int res = _nativeLangSpeaker.messageBox("FileBackupFailed", _pPublicInterface->getHSelf(), diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index d98b43cb..6859235c 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -6950,10 +6950,12 @@ Date::Date(int nbDaysFromNow) rawtime += (nbDaysFromNow * oneDay); timeinfo = localtime(&rawtime); - - _year = timeinfo->tm_year + 1900; - _month = timeinfo->tm_mon + 1; - _day = timeinfo->tm_mday; + if (timeinfo) + { + _year = timeinfo->tm_year + 1900; + _month = timeinfo->tm_mon + 1; + _day = timeinfo->tm_mday; + } } void Date::now() @@ -6963,10 +6965,12 @@ void Date::now() time(&rawtime); timeinfo = localtime(&rawtime); - - _year = timeinfo->tm_year + 1900; - _month = timeinfo->tm_mon + 1; - _day = timeinfo->tm_mday; + if (timeinfo) + { + _year = timeinfo->tm_year + 1900; + _month = timeinfo->tm_mon + 1; + _day = timeinfo->tm_mday; + } } diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 59869b94..9ad70aaf 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -849,6 +849,9 @@ bool FileManager::backupCurrentBuffer() TCHAR tmpbuf[temBufLen]; time_t ltime = time(0); struct tm* today = localtime(<ime); + if (!today) + return false; + generic_strftime(tmpbuf, temBufLen, TEXT("%Y-%m-%d_%H%M%S"), today); backupFilePath += TEXT("@");