Fix crash on opening file with wild card characters

And redefining Sci_PositionCR to 64 bits on x64 build for managing 2GB+ files.
(ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/11047#issuecomment-1021540298)

Fix #11098
This commit is contained in:
Don Ho 2022-01-28 04:17:45 +01:00
parent 44004d41d4
commit db3308329b
2 changed files with 14 additions and 8 deletions

View File

@ -643,16 +643,22 @@ void FileManager::closeBuffer(BufferID id, ScintillaEditView * identifier)
BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding, const TCHAR* backupFileName, FILETIME fileNameTimestamp)
{
//Get file size
int64_t fileSize = -1;
const TCHAR* pPath = filename;
if (!::PathFileExists(pPath))
{
pPath = backupFileName;
FILE* fp = generic_fopen(pPath, TEXT("rb"));
if (!fp)
return BUFFER_INVALID;
_fseeki64(fp, 0, SEEK_END);
int64_t fileSize = _ftelli64(fp);
fclose(fp);
}
if (pPath)
{
FILE* fp = generic_fopen(pPath, TEXT("rb"));
if (fp)
{
_fseeki64(fp, 0, SEEK_END);
fileSize = _ftelli64(fp);
fclose(fp);
}
}
// * the auto-completion feature will be disabled for large files
// * the session snapshotsand periodic backups feature will be disabled for large files

View File

@ -20,7 +20,7 @@ typedef size_t Sci_PositionU;
// For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE
typedef long Sci_PositionCR;
typedef intptr_t Sci_PositionCR;
#ifdef _WIN32
#define SCI_METHOD __stdcall