Skip to content

Commit d6acc5c

Browse files
committed
fix for getLanguageDesc bug #146
missing +1 for the allocated buffer for NPPM_GETLANGUAGENAME and NPPM_GETLANGUAGEDESC
1 parent ff83a52 commit d6acc5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

PythonScript/src/NotepadPlusWrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ intptr_t NotepadPlusWrapper::getCurrentNativeLangEncoding()
10061006
boost::python::str NotepadPlusWrapper::getLanguageName(int langType)
10071007
{
10081008
int size = callNotepad(NPPM_GETLANGUAGENAME, langType, NULL);
1009-
wchar_t* result(new wchar_t[size]);
1009+
wchar_t* result(new wchar_t[size+1]);
10101010
callNotepad(NPPM_GETLANGUAGENAME, langType, reinterpret_cast<LPARAM>(result));
10111011
std::shared_ptr<char> languageName = WcharMbcsConverter::tchar2char(result);
10121012
return boost::python::str(const_cast<const char *>(languageName.get()));
@@ -1015,7 +1015,7 @@ boost::python::str NotepadPlusWrapper::getLanguageName(int langType)
10151015
boost::python::str NotepadPlusWrapper::getLanguageDesc(int langType)
10161016
{
10171017
int size = callNotepad(NPPM_GETLANGUAGEDESC, langType, NULL);
1018-
wchar_t* result(new wchar_t[size]);
1018+
wchar_t* result(new wchar_t[size+1]);
10191019
callNotepad(NPPM_GETLANGUAGEDESC, langType, reinterpret_cast<LPARAM>(result));
10201020
std::shared_ptr<char> languageName = WcharMbcsConverter::tchar2char(result);
10211021
return boost::python::str(const_cast<const char *>(languageName.get()));

0 commit comments

Comments
 (0)