Fix too small buffer issue during add text macro playback

Fix #7642, close #7730
This commit is contained in:
Scott Sumner 2019-12-13 09:34:43 -05:00 committed by Don HO
parent 1c4157109f
commit 53452d96e0
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

View File

@ -834,9 +834,10 @@ void recordedMacroStep::PlayBack(Window* pNotepad, ScintillaEditView *pEditView)
if (_macroType == mtUseSParameter) if (_macroType == mtUseSParameter)
{ {
char ansiBuffer[3]; int byteBufferLength = ::WideCharToMultiByte(static_cast<UINT>(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, NULL, 0, NULL, NULL);
::WideCharToMultiByte(static_cast<UINT>(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, ansiBuffer, 3, NULL, NULL); auto byteBuffer = std::make_unique< char[] >(byteBufferLength);
auto lParam = reinterpret_cast<LPARAM>(ansiBuffer); ::WideCharToMultiByte(static_cast<UINT>(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, byteBuffer.get(), byteBufferLength, NULL, NULL);
auto lParam = reinterpret_cast<LPARAM>(byteBuffer.get());
pEditView->execute(_message, _wParameter, lParam); pEditView->execute(_message, _wParameter, lParam);
} }
else else