Fix file saving crash due to invald buffer

While trying to save a untitled empty document, user could open a existing
file that erases the untitled document's buffer, then save action make
Notepad++ crash:
https://www.youtube.com/watch?v=balHtvy4Toc
Fixes #1857, Closes #1904
This commit is contained in:
gszo123 2016-05-29 17:55:59 +02:00 committed by Don Ho
parent 4c26009a2e
commit 15561c8d69

View File

@ -453,6 +453,18 @@ bool Notepad_plus::doReload(BufferID id, bool alert)
bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
{
const int index = MainFileManager->getBufferIndexByID(id);
if (index == -1)
{
_nativeLangSpeaker.messageBox("BufferInvalidWarning",
_pPublicInterface->getHSelf(),
TEXT("Cannot save: Buffer is invalid."),
TEXT("Save failed"),
MB_OK | MB_ICONWARNING);
return false;
}
SCNotification scnN;
// Notify plugins that current file is about to be saved
if (!isCopy)