vcl/source/font/FeatureCollector.cxx | 8 +++++--- vcl/source/gdi/CommonSalLayout.cxx | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-)
New commits: commit f5c3a215fdd5505ebba8ae341d2146c3a4f739e3 Author: Khaled Hosny <kha...@aliftype.com> AuthorDate: Sat Aug 27 02:32:59 2022 +0200 Commit: خالد حسني <kha...@aliftype.com> CommitDate: Sat Aug 27 04:15:48 2022 +0200 vcl: Don’t leak hb_set_t Looks like I have a habit of never destroying these. Change-Id: I58e77908c68553222e34600aafb6fee186000a0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138893 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@aliftype.com> diff --git a/vcl/source/font/FeatureCollector.cxx b/vcl/source/font/FeatureCollector.cxx index 4f517bf6784a..9430a7833e12 100644 --- a/vcl/source/font/FeatureCollector.cxx +++ b/vcl/source/font/FeatureCollector.cxx @@ -170,19 +170,21 @@ void FeatureCollector::collectForTable(hb_tag_t aTableTag) hb_ot_layout_feature_get_lookups(m_pHbFace, aTableTag, nFeatureIdx, 0, &nLookups, aLookups.data()); unsigned int nAlternates = 0; + hb_set_t* pGlyphs = hb_set_create(); for (unsigned int nLookupIdx : aLookups) { - hb_set_t* aGlyphs = hb_set_create(); + hb_set_clear(pGlyphs); hb_ot_layout_lookup_collect_glyphs(m_pHbFace, aTableTag, nLookupIdx, nullptr, - aGlyphs, nullptr, nullptr); + pGlyphs, nullptr, nullptr); hb_codepoint_t nGlyphIdx = HB_SET_VALUE_INVALID; - while (hb_set_next(aGlyphs, &nGlyphIdx)) + while (hb_set_next(pGlyphs, &nGlyphIdx)) { nAlternates = std::max( nAlternates, hb_ot_layout_lookup_get_glyph_alternates( m_pHbFace, nLookupIdx, nGlyphIdx, 0, nullptr, nullptr)); } } + hb_set_destroy(pGlyphs); // Append the alternates to the feature parameters, keeping any // existing ones calculated from cvXX features above. diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 81f495afe981..fc28200ff98a 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -68,6 +68,8 @@ GenericSalLayout::GenericSalLayout(LogicalFontInstance &rFont) GenericSalLayout::~GenericSalLayout() { + if (mpVertGlyphs) + hb_set_destroy(mpVertGlyphs); } void GenericSalLayout::ParseFeatures(std::u16string_view aName) @@ -248,6 +250,7 @@ bool GenericSalLayout::HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 aVariationS hb_set_union(mpVertGlyphs, pGlyphs); } } + hb_set_destroy(pLookups); } return hb_set_has(mpVertGlyphs, nGlyphIndex) != 0;