Fix: Memory leak in ICUParagraphLayout::NextLine() (#11895)

This function calls icu::BreakIterator::createLineInstance() but does not clean up after it.

Instead use a static instance that is cloned (for thread-safety) and deleted as necessary.

(cherry picked from commit 6d276698b6)
This commit is contained in:
Peter Nelson
2024-01-27 20:13:42 +00:00
committed by Jonathan G Rennison
parent 5b052ff91a
commit 009fea0e14
5 changed files with 45 additions and 4 deletions

View File

@@ -12,6 +12,7 @@
#include "gfx_layout.h"
#include <unicode/brkiter.h>
#include <unicode/ustring.h>
/**
@@ -26,6 +27,11 @@ public:
static ParagraphLayouter *GetParagraphLayout(UChar *buff, UChar *buff_end, FontMap &fontMapping);
static size_t AppendToBuffer(UChar *buff, const UChar *buffer_last, char32_t c);
static void InitializeLayouter();
static std::unique_ptr<icu::BreakIterator> GetBreakIterator();
private:
static std::unique_ptr<icu::BreakIterator> break_iterator;
};
#endif /* GFX_LAYOUT_ICU_H */