vcl: Don’t release NULL CoreText objects

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 <khaled@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Khaled Hosny
2026-07-27 01:40:19 +02:00
committed by Khaled Hosny
parent 561ef2ae62
commit 3bdf95ee12
+6 -1
View File
@@ -38,10 +38,13 @@
static bool checkFontTypeSupported(CTFontDescriptorRef pFD, CFStringRef pFamilyName)
{
int nFormat;
int nFormat = kCTFontFormatUnrecognized;
CFNumberRef pFormat = static_cast<CFNumberRef>(CTFontDescriptorCopyAttribute(pFD, kCTFontFormatAttribute));
if (pFormat)
{
CFNumberGetValue(pFormat, kCFNumberIntType, &nFormat);
CFRelease(pFormat);
}
if (nFormat == kCTFontFormatPostScript)
{
@@ -52,9 +55,11 @@ static bool checkFontTypeSupported(CTFontDescriptorRef pFD, CFStringRef pFamilyN
{
CFDataRef pTable = CTFontCopyTable(pFont, kCTFontTableCFF, kCTFontTableOptionNoOptions);
if (pTable)
{
nFormat = kCTFontFormatOpenTypePostScript;
CFRelease(pTable);
}
}
CFRelease(pFont);
}