summaryrefslogtreecommitdiffstats
path: root/libass/ass_coretext.c
diff options
context:
space:
mode:
authorMarvin Scholz <epirat07@gmail.com>2019-11-06 23:44:16 +0100
committerwm4 <1387750+wm4@users.noreply.github.com>2019-11-07 17:31:49 +0100
commit517957eb70b757bdc4a51e62feac29095cd667e5 (patch)
treedd02e1a71f8b047bda9e0534f5afbb7d9be0b89c /libass/ass_coretext.c
parentbe0d1613f79a95073d18d96a60e1394abf9316a2 (diff)
downloadlibass-517957eb70b757bdc4a51e62feac29095cd667e5.tar.bz2
libass-517957eb70b757bdc4a51e62feac29095cd667e5.tar.xz
coretext: fix error handling in get_font_file
Fixes a crash in case a font does not has kCTFontURLAttribute, which is the case for example on macOS 10.15.1 for the ".AppleSymbolsFB" font. Fix #358
Diffstat (limited to 'libass/ass_coretext.c')
-rw-r--r--libass/ass_coretext.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libass/ass_coretext.c b/libass/ass_coretext.c
index 59a8a2d..7371f7c 100644
--- a/libass/ass_coretext.c
+++ b/libass/ass_coretext.c
@@ -96,7 +96,13 @@ static bool check_glyph(void *priv, uint32_t code)
static char *get_font_file(CTFontDescriptorRef fontd)
{
CFURLRef url = CTFontDescriptorCopyAttribute(fontd, kCTFontURLAttribute);
+ if (!url)
+ return NULL;
CFStringRef path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+ if (!path) {
+ SAFE_CFRelease(url);
+ return NULL;
+ }
char *buffer = cfstr2buf(path);
SAFE_CFRelease(path);
SAFE_CFRelease(url);
@@ -133,7 +139,7 @@ static void process_descriptors(ASS_Library *lib, ASS_FontProvider *provider,
int index = -1;
char *path = get_font_file(fontd);
- if (strcmp("", path) == 0) {
+ if (!path || strcmp("", path) == 0) {
// skip the font if the URL field in the font descriptor is empty
free(path);
continue;