Enhancement of preventing from null pointer exception of localtime
Fix #7952
This commit is contained in:
parent
d3cb2ceb36
commit
cfa3041c4d
@ -1481,6 +1481,8 @@ bool Notepad_plus::fileSave(BufferID id)
|
|||||||
struct tm *today;
|
struct tm *today;
|
||||||
|
|
||||||
today = localtime(<ime);
|
today = localtime(<ime);
|
||||||
|
if (today)
|
||||||
|
{
|
||||||
generic_strftime(tmpbuf, temBufLen, TEXT("%Y-%m-%d_%H%M%S"), today);
|
generic_strftime(tmpbuf, temBufLen, TEXT("%Y-%m-%d_%H%M%S"), today);
|
||||||
|
|
||||||
fn_bak += name;
|
fn_bak += name;
|
||||||
@ -1488,8 +1490,9 @@ bool Notepad_plus::fileSave(BufferID id)
|
|||||||
fn_bak += tmpbuf;
|
fn_bak += tmpbuf;
|
||||||
fn_bak += TEXT(".bak");
|
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",
|
int res = _nativeLangSpeaker.messageBox("FileBackupFailed",
|
||||||
_pPublicInterface->getHSelf(),
|
_pPublicInterface->getHSelf(),
|
||||||
|
@ -6950,11 +6950,13 @@ Date::Date(int nbDaysFromNow)
|
|||||||
rawtime += (nbDaysFromNow * oneDay);
|
rawtime += (nbDaysFromNow * oneDay);
|
||||||
|
|
||||||
timeinfo = localtime(&rawtime);
|
timeinfo = localtime(&rawtime);
|
||||||
|
if (timeinfo)
|
||||||
|
{
|
||||||
_year = timeinfo->tm_year + 1900;
|
_year = timeinfo->tm_year + 1900;
|
||||||
_month = timeinfo->tm_mon + 1;
|
_month = timeinfo->tm_mon + 1;
|
||||||
_day = timeinfo->tm_mday;
|
_day = timeinfo->tm_mday;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Date::now()
|
void Date::now()
|
||||||
{
|
{
|
||||||
@ -6963,11 +6965,13 @@ void Date::now()
|
|||||||
|
|
||||||
time(&rawtime);
|
time(&rawtime);
|
||||||
timeinfo = localtime(&rawtime);
|
timeinfo = localtime(&rawtime);
|
||||||
|
if (timeinfo)
|
||||||
|
{
|
||||||
_year = timeinfo->tm_year + 1900;
|
_year = timeinfo->tm_year + 1900;
|
||||||
_month = timeinfo->tm_mon + 1;
|
_month = timeinfo->tm_mon + 1;
|
||||||
_day = timeinfo->tm_mday;
|
_day = timeinfo->tm_mday;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EolType convertIntToFormatType(int value, EolType defvalue)
|
EolType convertIntToFormatType(int value, EolType defvalue)
|
||||||
|
@ -849,6 +849,9 @@ bool FileManager::backupCurrentBuffer()
|
|||||||
TCHAR tmpbuf[temBufLen];
|
TCHAR tmpbuf[temBufLen];
|
||||||
time_t ltime = time(0);
|
time_t ltime = time(0);
|
||||||
struct tm* today = localtime(<ime);
|
struct tm* today = localtime(<ime);
|
||||||
|
if (!today)
|
||||||
|
return false;
|
||||||
|
|
||||||
generic_strftime(tmpbuf, temBufLen, TEXT("%Y-%m-%d_%H%M%S"), today);
|
generic_strftime(tmpbuf, temBufLen, TEXT("%Y-%m-%d_%H%M%S"), today);
|
||||||
|
|
||||||
backupFilePath += TEXT("@");
|
backupFilePath += TEXT("@");
|
||||||
|
Loading…
Reference in New Issue
Block a user