From 10b628929502eb3f1ae7d371e78c2c7158dae958 Mon Sep 17 00:00:00 2001 From: attila Date: Wed, 7 May 2025 10:55:03 +0200 Subject: [PATCH] SimpleShapedText: Fix overallocating s32 buffer Prior to this commit we overallocated the s32 buffer. The buffer was unnecessarily padded by zeros, and the line stating this, wasn't actually dropping the null terminator. --- modules/juce_graphics/detail/juce_SimpleShapedText.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_graphics/detail/juce_SimpleShapedText.cpp b/modules/juce_graphics/detail/juce_SimpleShapedText.cpp index 130876bb2f..b5ceea7b84 100644 --- a/modules/juce_graphics/detail/juce_SimpleShapedText.cpp +++ b/modules/juce_graphics/detail/juce_SimpleShapedText.cpp @@ -879,7 +879,7 @@ struct Shaper const auto string32 = std::invoke ([this] { - std::vector s32 (CharPointer_UTF32::getBytesRequiredFor (string.getCharPointer())); + std::vector s32 ((size_t) string.length() + 1); string.copyToUTF32 (s32.data(), s32.size() * sizeof (juce_wchar)); jassert (! s32.empty()); s32.pop_back(); // dropping the null terminator