Skip to content

Commit

Permalink
Fix the crash issue for NPPM_GETNATIVELANGFILENAME
Browse files Browse the repository at this point in the history
  • Loading branch information
donho committed Sep 15, 2024
1 parent 45cd29f commit ea08a89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion PowerEditor/src/NppBigSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit ea08a89

Please sign in to comment.