Fix the crash issue for NPPM_GETNATIVELANGFILENAME

Fix #15627
This commit is contained in:
Don Ho 2024-09-15 18:57:55 +02:00
parent 45cd29f8ea
commit ea08a8929d
2 changed files with 6 additions and 1 deletions

View File

@ -985,6 +985,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
// Get the Current native language file name string. Use it after getting NPPN_READY notification to find out which native language is used.
// Users should call it with nativeLangFileName as NULL to get the required number of char (not including the terminating nul character),
// allocate language file name string buffer with the return value + 1, then call it again to get the current native language file name string.
// If there's no localization file aplied, the returned value is 0.
// wParam[in]: strLen is "language file name string" buffer length
// lParam[out]: language file name string receives all copied native language file name string
// Return the number of char copied/to copy

View File

@ -3761,7 +3761,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_GETNATIVELANGFILENAME:
{
string fileName = _nativeLangSpeaker.getFileName();
const char* fn = _nativeLangSpeaker.getFileName();
if (!fn) return 0;
string fileName = fn;
if (lParam != 0)
{
if (fileName.length() >= static_cast<size_t>(wParam))