Skip to content

Commit

Permalink
fix for getLanguageDesc bug #146
Browse files Browse the repository at this point in the history
missing +1 for the allocated buffer for NPPM_GETLANGUAGENAME and NPPM_GETLANGUAGEDESC
  • Loading branch information
chcg committed Apr 10, 2020
1 parent ff83a52 commit d6acc5c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PythonScript/src/NotepadPlusWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ intptr_t NotepadPlusWrapper::getCurrentNativeLangEncoding()
boost::python::str NotepadPlusWrapper::getLanguageName(int langType)
{
int size = callNotepad(NPPM_GETLANGUAGENAME, langType, NULL);
wchar_t* result(new wchar_t[size]);
wchar_t* result(new wchar_t[size+1]);
callNotepad(NPPM_GETLANGUAGENAME, langType, reinterpret_cast<LPARAM>(result));
std::shared_ptr<char> languageName = WcharMbcsConverter::tchar2char(result);
return boost::python::str(const_cast<const char *>(languageName.get()));
Expand All @@ -1015,7 +1015,7 @@ boost::python::str NotepadPlusWrapper::getLanguageName(int langType)
boost::python::str NotepadPlusWrapper::getLanguageDesc(int langType)
{
int size = callNotepad(NPPM_GETLANGUAGEDESC, langType, NULL);
wchar_t* result(new wchar_t[size]);
wchar_t* result(new wchar_t[size+1]);
callNotepad(NPPM_GETLANGUAGEDESC, langType, reinterpret_cast<LPARAM>(result));
std::shared_ptr<char> languageName = WcharMbcsConverter::tchar2char(result);
return boost::python::str(const_cast<const char *>(languageName.get()));
Expand Down

0 comments on commit d6acc5c

Please sign in to comment.