From 8fa54ec09a293431df580f1503768757884bbc5f Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 15 Dec 2020 08:01:27 +0100 Subject: [PATCH] Fixing Memory Leaking CTFontDescriptor Bug see https://trac.wxwidgets.org/ticket/19012 --- src/osx/carbon/font.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/osx/carbon/font.cpp b/src/osx/carbon/font.cpp index e206e2816d..b8db24c946 100644 --- a/src/osx/carbon/font.cpp +++ b/src/osx/carbon/font.cpp @@ -779,7 +779,8 @@ void wxNativeFontInfo::InitFromFont(CTFontRef font) { Init(); - InitFromFontDescriptor(CTFontCopyFontDescriptor(font) ); + wxCFRef desc(CTFontCopyFontDescriptor(font)); + InitFromFontDescriptor( desc ); } void wxNativeFontInfo::InitFromFontDescriptor(CTFontDescriptorRef desc) @@ -787,6 +788,7 @@ void wxNativeFontInfo::InitFromFontDescriptor(CTFontDescriptorRef desc) Init(); m_descriptor.reset(wxCFRetain(desc)); + int count = CFGetRetainCount(desc); m_ctWeight = GetCTWeight(desc); m_ctWidth = GetCTwidth(desc); @@ -1065,6 +1067,7 @@ bool wxNativeFontInfo::FromString(const wxString& s) if (descriptor != NULL) { InitFromFontDescriptor(descriptor); + CFRelease(descriptor); m_underlined = underlined; m_strikethrough = strikethrough; m_encoding = encoding;