From 53452d96e0bf17f9f5eaaeec9c6beb2424f6d8cd Mon Sep 17 00:00:00 2001 From: Scott Sumner <30118311+sasumner@users.noreply.github.com> Date: Fri, 13 Dec 2019 09:34:43 -0500 Subject: [PATCH] Fix too small buffer issue during add text macro playback Fix #7642, close #7730 --- PowerEditor/src/WinControls/shortcut/shortcut.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index 68afdd12..3b405569 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -834,9 +834,10 @@ void recordedMacroStep::PlayBack(Window* pNotepad, ScintillaEditView *pEditView) if (_macroType == mtUseSParameter) { - char ansiBuffer[3]; - ::WideCharToMultiByte(static_cast(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, ansiBuffer, 3, NULL, NULL); - auto lParam = reinterpret_cast(ansiBuffer); + int byteBufferLength = ::WideCharToMultiByte(static_cast(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, NULL, 0, NULL, NULL); + auto byteBuffer = std::make_unique< char[] >(byteBufferLength); + ::WideCharToMultiByte(static_cast(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, byteBuffer.get(), byteBufferLength, NULL, NULL); + auto lParam = reinterpret_cast(byteBuffer.get()); pEditView->execute(_message, _wParameter, lParam); } else