Enhancement of preventing from null pointer exception of localtime
Fix #7952
This commit is contained in:
parent
d3cb2ceb36
commit
cfa3041c4d
@ -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(),
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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("@");
|
||||
|
Loading…
Reference in New Issue
Block a user