From d6acc5c618e375cbec2b2d892fe58514089ccf59 Mon Sep 17 00:00:00 2001 From: Christian Grasser Date: Fri, 10 Apr 2020 19:55:33 +0200 Subject: [PATCH] fix for getLanguageDesc bug #146 missing +1 for the allocated buffer for NPPM_GETLANGUAGENAME and NPPM_GETLANGUAGEDESC --- PythonScript/src/NotepadPlusWrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PythonScript/src/NotepadPlusWrapper.cpp b/PythonScript/src/NotepadPlusWrapper.cpp index 6e613cc6..57caa72e 100644 --- a/PythonScript/src/NotepadPlusWrapper.cpp +++ b/PythonScript/src/NotepadPlusWrapper.cpp @@ -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(result)); std::shared_ptr languageName = WcharMbcsConverter::tchar2char(result); return boost::python::str(const_cast(languageName.get())); @@ -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(result)); std::shared_ptr languageName = WcharMbcsConverter::tchar2char(result); return boost::python::str(const_cast(languageName.get()));