From 7e11c5a4fbe6ad02c0b8e7464eef9c37b594b98c Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 17 Jul 2020 21:49:15 +1000 Subject: Fix truncation of locale due to not counting NUL. Add return code check. --- win32/PlatWin.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index d89ae2b89..a4bda5432 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1845,8 +1845,10 @@ void ScreenLineLayout::FillTextLayoutFormats(const IScreenLine *screenLine, IDWr const unsigned int localNameSize = pfm->pTextFormat->GetLocaleNameLength(); std::vector localName(localNameSize + 1); - pfm->pTextFormat->GetLocaleName(localName.data(), localNameSize); - textLayout->SetLocaleName(localName.data(), textRange); + const HRESULT hrLocale = pfm->pTextFormat->GetLocaleName(localName.data(), localNameSize + 1); + if (SUCCEEDED(hrLocale)) { + textLayout->SetLocaleName(localName.data(), textRange); + } textLayout->SetFontStretch(pfm->pTextFormat->GetFontStretch(), textRange); -- cgit v1.2.3