From 3bdf95ee128166e60e29fe2648725825eb825add Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sat, 25 Jul 2026 21:54:31 +0300 Subject: [PATCH] =?UTF-8?q?vcl:=20Don=E2=80=99t=20release=20NULL=20CoreTex?= =?UTF-8?q?t=20objects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CTFontCopyTable() returns NULL if the table is not in the font, which is the case we are checking for here, and CFRelease() is documented to crash on NULL. Similarly CTFontDescriptorCopyAttribute() can return NULL, in which case the font format was left uninitialized as well. Change-Id: Idfa570d704244cbe505104934bfca456b2b54451 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208633 Reviewed-by: Khaled Hosny Tested-by: Jenkins --- vcl/quartz/SystemFontList.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/vcl/quartz/SystemFontList.cxx b/vcl/quartz/SystemFontList.cxx index fb0ea10dbaa1..015bab1a6b0a 100644 --- a/vcl/quartz/SystemFontList.cxx +++ b/vcl/quartz/SystemFontList.cxx @@ -38,10 +38,13 @@ static bool checkFontTypeSupported(CTFontDescriptorRef pFD, CFStringRef pFamilyName) { - int nFormat; + int nFormat = kCTFontFormatUnrecognized; CFNumberRef pFormat = static_cast(CTFontDescriptorCopyAttribute(pFD, kCTFontFormatAttribute)); - CFNumberGetValue(pFormat, kCFNumberIntType, &nFormat); - CFRelease(pFormat); + if (pFormat) + { + CFNumberGetValue(pFormat, kCFNumberIntType, &nFormat); + CFRelease(pFormat); + } if (nFormat == kCTFontFormatPostScript) { @@ -52,8 +55,10 @@ static bool checkFontTypeSupported(CTFontDescriptorRef pFD, CFStringRef pFamilyN { CFDataRef pTable = CTFontCopyTable(pFont, kCTFontTableCFF, kCTFontTableOptionNoOptions); if (pTable) + { nFormat = kCTFontFormatOpenTypePostScript; - CFRelease(pTable); + CFRelease(pTable); + } } CFRelease(pFont); }